I have a NetCDF obtained from a WRF simulation with a curvilinear grid with the following attributes:
points=48000 (250x192)
XLONG : -46.01144 to 42.05725 degree_east
XLAT : 24.87103 to 63.47381 degree_north
20km of horizontal resolution
I want to create new coordinates for the same domain, but with a horizontal resolution of 5km. I would like to do it with xarray if it's possible.
At present it seems difficult to deal with curvilinear grids with xarray (https://github.com/pydata/xarray/issues/2281)
But you can use cdo to transform your grid to a regular grid using cdo (http://gradsusr.org/pipermail/gradsusr/2014-February/036493.html)
And then you can actually regrid to any resolution you may want.
You can follow the example at http://xarray.pydata.org/en/stable/interpolation.html#example to interpolate to a higher resolution.
Related
I am making maps of meteorological data (x,y-coordinates in m) using matplotlib.pyplot.contourf(). I want to plot a coastline, but all the examples I find on internet use lat-lon data (with cartopy or basemap).
Is there a way (without transforming the data to a lat-lon grid) to plot a coastline on my cartesian grid? I know size of the grid, and its center's lat-lon coordinates.
I haven't tried anything but look for similar examples, which I could not find.
The solution is to use cartopy's gnomonic projection: https://scitools.org.uk/cartopy/docs/v0.15/crs/projections.html#gnomonic , e.g.
proj =ccrs.Gnomonic(central_latitude=0, central_longitude= 0)
The origin of the data need to be specified (in lat-lon), and it expects the data coordinates to be distance in meters from that origin. Then, the normal cartopy features (like coastlines) work as usual.
I am having a 2d numpy array serving georeferenced information like a radar image or a temperature field. I know the coordinates of all points and can define the bounding box in EPSG:3857.
What is the fastest way to plot this data into a tms tile pyramid?
A well known solution is to plot data as a geotiff and use gdal2tiles but this is very slow for hgh zoom levels >10.
I hope anyone can recommend a software doing this or can provide a code snippet. Thanks a lot!
I have a dataset of points (latitude, longitude, value) and i want to create a Geotiff file from these points.
latitude,longitude and the value are float32 numbers
I want to generate a custom raster that interpolate over those points.
Link
I want to obtain a grid as in the link above and for every point in the grid have a value (computed from original points with some kind of interpolation i guess)
The tutorial you pointed in your question is the theory behind gdal_grid utility:
https://www.gdal.org/gdal_grid.html
Check the bottom of the page for examples of how to interpolate a geotiff from scattered data.
For how to use in python:
https://gis.stackexchange.com/questions/254330/python-gdal-grid-correct-use
I am plotting some NETCDF data, handled by xarray in Matplotlib using a Cartopy wrapper for the map projections. When I produce a filled contour plot (contourf), I end up with a 'seam' at longitude zero (where my data longitudes begin and end). Is there an in-line way to interpolate between longitude[-1] and longitude[0], perhaps by treating the data as periodic or something?
Please see the attached graphic for an example:
You should add a cyclic point to your data array and its longitude coordinate using the add_cyclic_point function: http://scitools.org.uk/cartopy/docs/v0.16/cartopy/util/util.html#cartopy.util.add_cyclic_point.
I'm working with some instrument data that has records the temperature at a specific latitude, longitude, and pressure (height) coordinate. I need to create a 3d grid from this instrument data that I can then use to take a vertical cross sections of the interpolated gridded data. I've looked at pretty much every interpolation function/library I can find and I'm still having trouble just wrapping my head around how to do this.
I'd prefer not to use Mayavi, since it seems to bug out on my school's server and I'd rather not try to deal with fixing it right now.
The data is currently in 4 separate 1d arrays and I used those to mock up some scatter plots of what I'm trying to get.
Here is the structure of my instrument data points:
And here is what I'm trying to create:
Ultimately, I'd like to create some kind of 3d contour from these points that I can take slices of. Each of the plotted points has a corresponding temperature attached to it, which is really what I think is throwing me off in terms of dimensions and whatnot.
There are a few options to go from the unstructured data which you have to a structured dataset.
The simplest option might be to use the scipy interpolate.griddata method which can interpolate unstructured points using, linear or cubic interpolation.
Another option is to define your grid and then average all of the unstructured points which fall into each grid cell, giving you some gridded representation of the data. You could use a tool such as CIS to do this easily (full disclosure, I wrote this package to do exactly this kind of thing).
Or, there are more complicated methods of interpolating the data by trying to determine the most likely value of the grid points based on the unstructured data, for example using kriging with the pyKriging package, though I've never used this.