Working with generic raster formats

GeoTIFF

Pygaarst raster module provides a custom GeoTIFF class with methods and properties that aim at making it easy to open and process GeoTIFF files. It works with both single and multi-band GeoTIFF files. Under the hood, the GeoTIFF class uses GDAL, so the instance attributes it makes available are will look familiar to those who work with GDAL. The default public methods and attributes are:

class pygaarst.raster.GeoTIFF(filepath)

Represents a GeoTIFF file for data access and processing and provides a number of useful methods and attributes.

Arguments:
filepath (str): the full or relative file path
clone(newpath, newdata)

Creates new GeoTIFF object from existing: new data, same georeference.

Arguments:
newpath: valid file path newdata: numpy array, 2 or 3-dim
Returns:
A raster.GeoTIFF object
ij2xy(i, j)

Converts array index pair(s) to easting/northing coordinate pairs(s).

NOTE: array coordinate origin is in the top left corner whereas easting/northing origin is in the bottom left corner. Easting and northing are floating point numbers, and refer to the top-left corner coordinate of the pixel. i runs from 0 to nrow-1, j from 0 to ncol-1. For i=nrow and j=ncol, the bottom-right corner coordinate of the bottom-right pixel will be returned. This is identical to the bottom- right corner.

Arguments:
i (int): scalar or array of row coordinate index j (int): scalar or array of column coordinate index
Returns:
x (float): scalar or array of easting coordinates y (float): scalar or array of northing coordinates
simpleplot()

Quick and dirty plot of each band (channel, dataset) in the image. Requires Matplotlib.

xy2ij(x, y, precise=False)

Convert easting/northing coordinate pair(s) to array coordinate pairs(s).

NOTE: see note at ij2xy()

Arguments:
x (float): scalar or array of easting coordinates y (float): scalar or array of northing coordinates precise (bool): if true, return fractional array coordinates
Returns:
i (int, or float): scalar or array of row coordinate index j (int, or float): scalar or array of column coordinate index
Lat

Latitude coordinate of each pixel corner, as an array

Lat_pxcenter

Latitude coordinate of each pixel center, as an array

Lon

Longitude coordinate of each pixel corner, as an array

Lon_pxcenter

Longitude coordinate of each pixel center, as an array

coordtrans

A PROJ4 Proj object, which is able to perform coordinate transformations

data

2D numpy array for single-band GeoTIFF file data. Otherwise, 3D.

delx

The sampling distance in x-direction, in physical units (eg metres)

dely

The sampling distance in y-direction, in physical units (eg metres). Negative in northern hemisphere.

easting

The x-coordinates of first row pixel corners, as a numpy array: upper-left corner of upper-left pixel to upper-right corner of upper-right pixel (ncol+1).

northing

The y-coordinates of first column pixel corners, as a numpy array: lower-left corner of lower-left pixel to upper-left corner of upper-left pixel (nrow+1).

proj4

The dataset’s coordinate reference system as a PROJ4 string

projection

The dataset’s coordinate reference system as a Well-Known String

x_pxcenter

The x-coordinates of pixel centers, as a numpy array ncol.

y_pxcenter

y-coordinates of pixel centers, nrow.

HDF4 and HDF-EOS

[TBC]

HDF5

Pygaarst raster module provides a custom HDF5 class with methods and properties that aim at making it easy to open and process files in

class pygaarst.raster.HDF5(filepath)

A class providing access to a generic HDF5

Arguments:
filepath (str): full or relative path to the data file