

- Interpolate numpy raster x y z download#
- Interpolate numpy raster x y z free#
- Interpolate numpy raster x y z windows#
GMT should also able to make what you need and there is a python interface, at least under development. There are some tutorials that can put you on the right track. You can also use R, that might be a smart solution if you intend to do some more demanding statistical analysis later. For more complicated spatial processes (clip a raster from a vector polygon e.g.) GDAL is a great library. numpy and scipy are good packages for interpolation and all array processes.
Interpolate numpy raster x y z free#
Python is also free and there is a great community at SE and elsewhere. This will somehow give you more control of your workflow. cities or extract the interpolated temperature for a location.Īlternatively (according to your updated question), you can use Python. With a GIS option, it is easy to also plot e.g. A few searches at GIS SE can help you out if you get stuck.
Interpolate numpy raster x y z download#
Download a free coastline vector and clip your raster with the coastline.

Add delimited text layer and try raster interpolation. The easiest solution for this simple task would be to use a GIS software, e.g. I suggest you play with each to see what yields the best result for your dataset. Besides linear, this can also be cubic or nearest.

Notice also the method argument to griddata. You should replace this mask with the landmask on your grid. This example includes a simple way to mask the field.xi and yi are target grid axes - these will be your target longitude and latitude coordinates, which must match your landmask field.z are the values of points - this corresponds to your temperature observations from stations.x and y are locations of points - these correspond to lon and lat values of your stations.Here is an example: import matplotlib.pyplot as plt (1600, 1600, -76.322, 30.It is straightforward to do so with numpy,, and matplotlib. Parser.add_argument("filename",help='raster file from which to interpolate a (1/3,1/3) point from from') Thank you for the hints in your question. version = 0.14.0, it happily works on some 1600x1600 model output. I get the same error as you do with scipy. I think older versions assume irregular grids and don't take advantage of the regular grids. astype(band_array.dtype) to make the output data type the same as the input array. Note that the result will be returned with an apparent higher precision than the source data, since it is up-classed to NumPy's dtype('float64') data type. # Use the differences to weigh the four raster values # Calculate differences from point to bounding raster midpoints # Test array bounds to ensure point is within raster midpoints # Special case where point is on upper bounds # Calculate raster lower bound indices from point I've translated the formula below (from Wikipedia) into Python-speak to yield the following algorithm, which appears to work. but I much prefer bilinear interpolation methods) (Note: the nearest neighbor interpolation algorithm is easy cake: from numpy import argmin, NANĭef nearest_neighbor(px, py, no_data=NAN): Has anyone come across a good bilinear interpolation algorithm, preferably in Python, possibly tailored with NumPy? Any hints or advice? I don't see why I should have a memory error, since my raster is 317×301, and the bilinear algorithm should not be difficult. I'll admit, I have limited confidence in this SciPy function, as the bounds_error or fill_value parameters don't work as documented. Self.tck = fitpack.bisplrep(self.x, self.y, self.z, kx=kx, ky=ky, s=0.)įile "C:\Python25\Lib\site-packages\scipy\interpolate\fitpack.py", line 873, in bisplrep

Interpolate numpy raster x y z windows#
However I get a memory error on my 32-bit Windows system with a 317×301 raster: Traceback (most recent call last):įile "C:\Python25\Lib\site-packages\scipy\interpolate\interpolate.py", line 125, in _init_ Up to now, I've tried SciPy's interp2d function: from scipy import interpolateīilinterp = interpolate.interp2d(ax, ay, band_array, kind='linear') Nx, ny = source.RasterXSize, source.RasterYSizeīand_array = source.GetRasterBand(1).ReadAsArray()Īx = array( + ix*gt + gt/2.0 for ix in range(nx)])Īy = array( + iy*gt + gt/2.0 for iy in range(ny)]) Here is where I'm at: from osgeo import gdal I have a raster that I'd like to do some point interpolations with.
