io.raster

Utilities for reading and operating on raster data

Source code

General Attributes and Methods

class grounding_zones.io.raster(**kwargs)[source]

Utilities for using raster files

from_file(input_file, format=None, **kwargs)[source]

Read a raster file from an input format

Parameters:
input_file: str

path or memory map for raster file

format: str

format of input file

**kwargs: dict

Keyword arguments for file reader

interp(x, y, order=0, reducer=<ufunc 'ceil'>)[source]

Sample raster data at points

Parameters:
datain: np.ndarray

input data grid to be interpolated

x: np.ndarray

output x-coordinates

y: np.ndarray

output y-coordinates

order: int, default 0

interpolation order

  • 0: nearest-neighbor interpolation

  • k: bivariate spline interpolation of degree k

reducer: obj, default np.ceil

operation for converting mask to boolean

warp(x, y, order=0, reducer=<ufunc 'ceil'>)[source]

Interpolate raster data to a new grid

Parameters:
datain: np.ndarray

input data grid to be interpolated

x: np.ndarray

output x-coordinate array

y: np.ndarray

output y-coordinate array

order: int, default 0

interpolation order

  • 0: nearest-neighbor interpolation

  • k: bivariate spline interpolation of degree k

reducer: obj, default np.ceil

operation for converting mask to boolean

get_latlon(srs_proj4=None, srs_wkt=None, srs_epsg=None)[source]

Get the latitude and longitude of grid cells

Parameters:
srs_proj4: str or NoneType, default None

PROJ4 projection string

srs_wkt: str or NoneType, default None

Well-Known Text (WKT) projection string

srs_epsg: int or NoneType, default None

EPSG projection code

Returns:
longitude: np.ndarray

longitude coordinates of grid cells

latitude: np.ndarray

latitude coordinates of grid cells

copy()[source]

Copy a raster object to a new raster object

flip(axis=0)[source]

Reverse the order of data and dimensions along an axis

Parameters:
axis: int, default 0

axis to reorder