gazar.grid¶
-
gazar.grid.
utm_proj_from_latlon
(latitude, longitude, as_wkt=False, as_osr=False)[source]¶ Returns UTM projection information from a latitude, longitude corrdinate pair.
Parameters: Returns: Defaults to the proj.4 string.
Return type: str
orosr.SpatialReference()
-
gazar.grid.
geotransform_from_yx
(y_arr, x_arr, y_cell_size=None, x_cell_size=None)[source]¶ Calculates geotransform from arrays of y and x coords. Assumes Y max and X min are at [0,0].
Parameters: Returns: geotransform: (x_min, x_cell_size, x_skew, y_max, y_skew, -y_cell_size)
Return type:
-
gazar.grid.
resample_grid
(original_grid, match_grid, to_file=False, output_datatype=None, resample_method=<Mock id='139942203770960'>, as_gdal_grid=False)[source]¶ This function resamples a grid and outputs the result to a file.
- Based on: http://stackoverflow.com/questions/10454316/how-to-project-and-
- resample-a-grid-to-match-another-grid-with-gdal-python
Parameters: - original_grid (
str
orgdal.Dataset()
orGDALGrid()
) – The original grid dataset. - match_grid (
str
orgdal.Dataset()
orGDALGrid()
) – The grid to match. - to_file (
str
or bool, optional) – Default is False, which returns an in memory grid. Ifstr
, it writes to file. - output_datatype (
osgeo.gdalconst()
, optional) – A valid datatype from gdalconst (Ex. gdalconst.GDT_Float32). - resample_method (
osgeo.gdalconst()
, optional) – A valid resample method from gdalconst. Default is gdalconst.GRA_Average. - as_gdal_grid (bool, optional) – Return as
GDALGrid()
. Default is False.
Returns: If to_file is a
str
, then it returns None. Otherwise, if to_file is False then it returns agdal.Dataset()
unless as_gdal_grid is True. Then, it returnsGDALGrid()
.Return type: None or
gdal.Dataset()
orGDALGrid()
-
gazar.grid.
gdal_reproject
(src, dst=None, src_srs=None, dst_srs=None, epsg=None, error_threshold=0.125, resampling=<Mock id='139942203771088'>, as_gdal_grid=False)[source]¶ Reproject a raster image.
- Based on: https://github.com/OpenDataAnalytics/
- gaia/blob/master/gaia/geo/gdal_functions.py
Parameters: - src (
str
orgdal.Dataset()
orGDALGrid()
) – The source image. - dst (
str
, optional) – The filepath of the output image to write to. - src_srs (
osr.SpatialReference()
, optional) – The source image projection. - dst_srs (
osr.SpatialReference()
, optional) – The destination projection. If not provided, the code will use epsg. - epsg (int, optional) – The EPSG code to reproject to. If not provided, the code will use dst_srs.
- error_threshold (float, optional) – Default is 0.125 (same as gdalwarp commandline).
- resampling (
osgeo.gdalconst()
) – Method to use for resampling. Default method is gdalconst.GRA_NearestNeighbour. - as_gdal_grid (bool, optional) – Return as
GDALGrid()
. Default is False.
Returns: By default, it returns gdal.Dataset. It will return
GDALGrid()
if as_gdal_grid is True.Return type: gdal.Dataset()
orGDALGrid()