Skip to content

MapProjection

Records the map projection and the size of the pixels in a layer.

Note: It is very common to find that round errors creep into pixel scale values in GeoTIFFs from different sources, and so MapProjection tolerates small amounts of difference between pixel scales that are below a single metre in resolution.

Parameters:

Name Type Description Default
name

The map projection used in WKT format, or as "epsg:xxxx" or "esri:xxxx".

required
xstep float

The number of units horizontal distance a step of one pixel makes in the map projection.

required
ystep float

The number of units vertical distance a step of one pixel makes in the map projection.

required

Attributes:

Name Type Description
name str

The map projection used in WKT format.

xstep

The number of units horizontal distance a step of one pixel makes in the map projection.

ystep

The number of units vertical distance a step of one pixel makes in the map projection.

Examples:

Create a map projection using an EPSG code:

>>> proj_wgs84 = MapProjection("epsg:4326", 0.001, -0.001)

Create a projection using an ESRI code:

>>> proj_esri = MapProjection("esri:54030", 1000, -1000)

from_affine(crs, transform) classmethod

Build a map projection from a CRS and Affine transform.

Useful for instance when mixing Yirgacheffe with Rasterio.

Parameters:

Name Type Description Default
crs

Either a string or a CRS object from pyproj or rasterio.

required
transform Affine

an Affine transform object.

required

Returns:

Type Description
MapProjection

A map projection based on the CRS and pixel size provided.

round_up_pixels(x, y)

In general we round up pixels, as we don't want to lose range data, but floating point math means we will get errors where the value of pixel scale value rounds us to a tiny faction of a pixel up, and so math.ceil would round us up for microns worth of distance.