reVX.handlers.geotiff.Geotiff

class Geotiff(fpath, chunks=(128, 128))[source]

Bases: object

GeoTIFF handler object.

Parameters:
  • fpath (str) – Path to .tiff file.

  • chunks (tuple) – GeoTIFF chunk (tile) shape/size.

Methods

close()

Close the rasterio source object

write(out_fp, profile, values[, dtype])

Write values to GeoTIFF file with given profile.

Attributes

bands

Get number of GeoTiff bands

dtype

GeoTiff array dtype

iarr

Get an array of 1D index values for the flattened geotiff extent.

lat_lon

Get latitude and longitude coordinate arrays

latitude

Get latitude coordinates array

longitude

Get longitude coordinates array

meta

Lat lon to y, x coordinate mapping

n_cols

Get the number of Geotiff columns.

n_rows

Get the number of Geotiff rows.

profile

GeoTiff geospatial profile

shape

Get the Geotiff shape tuple (n_rows, n_cols).

tiff_shape

Tiff array shape (bands, y, x)

values

Full DataArray in [bands, y, x] dimensions

property profile

GeoTiff geospatial profile

Returns:

_profile (dict) – Dictionary of geo-spatial attributes needed to create GeoTiff

property dtype

GeoTiff array dtype

Returns:

dtype (str) – Dtype of data in GeoTiff

property iarr

Get an array of 1D index values for the flattened geotiff extent.

Returns:

iarr (np.ndarray) – Uint array with same shape as geotiff extent, representing the 1D index values if the geotiff extent was flattened (with default flatten order ‘C’)

property tiff_shape

Tiff array shape (bands, y, x)

Returns:

shape (tuple) – (bands, y, x)

property shape

Get the Geotiff shape tuple (n_rows, n_cols).

Returns:

shape (tuple) – 2-entry tuple representing the full GeoTiff shape.

property n_rows

Get the number of Geotiff rows.

Returns:

n_rows (int) – Number of row entries in the full geotiff.

property n_cols

Get the number of Geotiff columns.

Returns:

n_cols (int) – Number of column entries in the full geotiff.

property bands

Get number of GeoTiff bands

Returns:

bands (int)

property lat_lon

Get latitude and longitude coordinate arrays

Returns:

tuple

property latitude

Get latitude coordinates array

Returns:

ndarray

property longitude

Get longitude coordinates array

Returns:

ndarray

property meta

Lat lon to y, x coordinate mapping

Returns:

pd.DataFrame

property values

Full DataArray in [bands, y, x] dimensions

Returns:

ndarray

close()[source]

Close the rasterio source object

static write(out_fp, profile, values, dtype=None)[source]

Write values to GeoTIFF file with given profile.

Parameters:
  • out_fp (str) – Path to GeoTIFF output file to save data to.

  • profile (dict) – GeoTIFF profile (attributes).

  • values (ndarray) – GeoTIFF data to save.

  • dtype (str, optional) – Type of data being stored. If None, the data dtype is inferred from the values input itself.