pygeoutils._utils
#
Some utilities for manipulating GeoSpatial data.
Module Contents#
- pygeoutils._utils.get_gtiff_attrs(resp, ds_dims=None, driver=None, nodata=None)#
Get nodata, CRS, and dimension names in (vertical, horizontal) order from raster in bytes.
- Parameters:
resp (
bytes
) – Raster response returned from a wed service request such as WMSds_dims (
tuple
ofstr
, optional) – The names of the vertical and horizontal dimensions (in that order) of the target dataset, default to None. If None, dimension names are determined from a list of common names.driver (
str
, optional) – A GDAL driver for reading the content, defaults to automatic detection. A list of the drivers can be found here: https://gdal.org/drivers/raster/index.htmlnodata (
float
orint
, optional) – The nodata value of the raster, defaults to None, i.e., is determined from the raster.
- Returns:
Attrs
– No data, CRS, and dimension names for vertical and horizontal directions or a list of the existing dimensions if they are not in a list of common names.- Return type:
Attrs
- pygeoutils._utils.get_transform(ds, ds_dims=('y', 'x'))#
Get transform of a
xarray.Dataset
orxarray.DataArray
.- Parameters:
ds (
xarray.Dataset
orxarray.DataArray
) – The dataset(array) to be maskedds_dims (
tuple
, optional) – Names of the coordinames in the dataset, defaults to("y", "x")
. The order of the dimension names must be (vertical, horizontal).
- Returns:
rasterio.Affine
,int
,int
– The affine transform, width, and height- Return type:
- pygeoutils._utils.transform2tuple(transform)#
Convert an affine transform to a tuple.
- pygeoutils._utils.xd_write_crs(ds, crs=None, grid_mapping_name=None)#
Write geo reference info into a dataset or dataarray.
- Parameters:
ds (
xarray.Dataset
orxarray.DataArray
) – Input dataset(array)crs (
pyproj.CRS
orstr
orint
, optional) – Target CRS to be written, defaults tods.rio.crs
grid_mapping_name (
str
, optional) – Target grid mapping, defaults tods.rio.grid_mapping
- Returns:
xarray.Dataset
orxarray.DataArray
– The dataset(array) with CRS info written.- Return type:
XD