geopyspark.geotrellis.key_conversion module¶
A module to provide facilites for converting between layout keys and spatial objects. These facilities aim to bridge between the various layouts, SpatialKey
s, and geometry.
-
class
geopyspark.geotrellis.key_conversion.
KeyTransform
(layout, crs=None, extent=None, cellsize=None, dimensions=None)¶ Provides functions to move from keys to geometry and vice-versa.
Tile Layers have an underlying RDD which is keyed by either
SpatialKey
orSpaceTimeKey
. Each key represents a region in space, depending on a choice of layout. In order to enable the conversion of keys to regions, and of geometry to keys, theKeyTransform
class is provided. This class is constructed with a layout, which is eitherGlobalLayout
,LocalLayout
, or aLayoutDefinition
. Global layouts use power-of-two pyramids over the world extent, while local layouts operate over a defined extent and cellsize.NOTE: LocalLayouts will encompass the requested extent, but the final layout may include ``SpatialKey``s which only partially cover the requested extent. The upper-left corner of the resulting layout will match the requested extent, but the right and bottom edges may be beyond the boundaries of the requested extent.
NOTE: GlobalLayouts require pyproj to be installed.
:param layout(
GlobalLayout
orLocalLayout
: orLayoutDefinition
): a definition of the layout scheme defining the key structure. :param crs: Used only when layout isGlobalLayout
. Target CRS of reprojection.Either EPSG code, well-known name, or a PROJ.4 stringParameters: - extent (
Extent
) – Used only for ``LocalLayout``s. The area of interest. - cellsize (tup of (float, float)) – Used only for
LocalLayout``s. The (width, height) in extent units of a pixel. Cannot be specified simultaneously with ``dimensions
. - dimensions (tup of (int, int)) – Used only for
LocalLayout``s. The number of (columns, rows) of pixels over the entire extent. Cannot be specified simultaneously with ``cellsize
.
-
extent_to_keys
(extent)¶ Returns the keys in the layout intersecting/covered by a given extent.
Parameters: extent ( Extent
) – The extent to find the matching keys for.Returns: [ SpatialKey
]
-
geometry_to_keys
(geom)¶ Returns the keys corresponding to grid cells that intersect/are covered by a given Shapely geometry.
Parameters: geom ( Geometry
) – The geometry to find the matching keys for.Returns: [ SpatialKey
]
-
key_to_extent
(key, *args)¶ Returns the Extent corresponding to a given key.
Parameters: key ( SpatialKey
orSpaceTimeKey
or int) – The key to find the extent for. If of type int, then this parameter is the column of the key, and the call must provide a single additional int value in the args parameter to serve as the row of the key.Returns: Extent
- extent (