regrid_from_geotiff#

pycraf.pathprof.regrid_from_geotiff(geotiff, lons, lats, band=1, return_raw=False)[source]#

Retrieve interpolated GeoTiff raster values for given WGS84 coordinates (longitude, latitude).

Most GeoTiff raster maps will be based on reference frames other than geographic (WGS84), such that it is often necessary to reproject a map, e.g. to get the data values for the positions present in an terrain height map such as SRTM, which is the basis for path propagation loss calculations. By means of nearest neighbour interpolation one can quickly reproject (or regrid) a GeoTiff raster map to the required positions.

Parameters:
geotiffDatasetReader instance

A geotiff raster map opened with the Python package Rasterio.

lons, latsQuantity

Geographic longitudes/latitudes (WGS84) [deg]

bandint, Optional (default: 1)

The GeoTiff band to use.

return_rawBoolean, Optional (default: False)

Also return the original data (in the same window). This may be useful if the normalization of the data is important (e.g., for a population map rather than a population density map).

Returns:
geo_data_regriddedndarray

Regridded values of the input raster map on the given longitude and latitude positions. If the input GeoTiff has more than one band and you need to regrid several of the bands, please run the function repeatedly, specifying the band parameter.

geo_data_rawndarray

Only returned when return_raw == True Original/raw values of the input raster map in the the same window that was queried with this function.

Notes

If requested geo positions are all to close to the edge of the geotiff file, the interpolation can fail (interpolate will raise a ValueError in such cases).