Area
Class to hold a geospatial area. Can optionally have a projection associated.
Ideally areas should always have a projection associated with them, however some data sources, notably polygon datasets like GeoJSON, do not store this, so we have to allow for projectionless areas.
You can use set operators | (union) and & (intersection) on Areas.
If two areas are intersected or unioned and they have the same map projection and geospatial pixel size, but they do not perfectly align on the same pixel grid, then the operation will be performed based on nearest neighbour alignment of the pixel grids, such that the resulting area is still pixel aligned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
left
|
float
|
Left most point in the projection space. |
required |
top
|
float
|
Top most point in the projection space. |
required |
right
|
float
|
Right most point in the projection space. |
required |
bottom
|
float
|
Bottom most point in the projection space. |
required |
projection
|
MapProjection | None
|
An optional map projection. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
left |
float
|
Left most point in the projection space. |
top |
float
|
Top most point in the projection space. |
right |
float
|
Right most point in the projection space. |
bottom |
float
|
Bottom most point in the projection space. |
projection |
MapProjection | None
|
An optional map projection. |
geo_transform
property
Returns the GDAL geo transform for the area.and()
Attempts to call this on an area with no projection will raise a ValueError.
Returns:
| Type | Description |
|---|---|
tuple[float, float, float, float, float, float]
|
A tuple of floats for the GDAL geo transform record. |
is_world
property
Returns true if this is a global area, independent of projection.
Returns:
| Type | Description |
|---|---|
bool
|
True if the Area was created with |
pixel_dimensions
property
Returns the size in pixels for this area in its given projection.
Attempts to call this on an area with no projection will raise a ValueError.
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
A tuple of the width and height. |
grow(offset)
Expand the area in all directions by the given amount.
Generates a new area that is an expanded version of the current area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
float
|
The amount by which to grow the area. |
required |
Returns:
| Type | Description |
|---|---|
Area
|
A new area of the expanded size. |
overlaps(other)
Check if this area overlaps with another area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Area
|
The other area to compare this area with. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the two areas intersect, otherwise false. |
project_like(other)
Takes a projectionless area and maps it onto a map projection based on an existing area.
Because map projections have pixel scales associated with them, the area may be expanded to ensure that the original area is within the bounds when mapped to the pixel space of the other area.
Will raise an exception if this area already has a map projection set, or if the other area does not.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Area
|
The other area to take the map projection from. |
required |
Returns:
| Type | Description |
|---|---|
Area
|
A new area with the projection map. |
reproject(target_projection)
Takes an area and projects it.
world()
staticmethod
Creates an area that covers the entire planet.
Returns:
| Type | Description |
|---|---|
Area
|
An area where the extents are nan, but is_world returns true. |