mgrs.MGRSGrid
The 10 km MGRS grid squares covering an area of interest.
Usage
mgrs.MGRSGrid(
filter_geometry,
resolution=10.0,
)A grid specification rather than a dataset: it stores no pixels, only the rule that maps each MGRS reference to exactly one CRS, affine transform, and array shape. Resampling two sources onto the same grid square makes them co-registered by construction.
Squares are 10 x 10 km and tile their UTM zone without overlap, so unlike the Sentinel-2 tiling each location is stored once. Squares from neighbouring UTM zones can still overlap near a zone boundary, since each zone’s grid is built independently.
Indexing with an integer yields an MGRSGeoBox; slicing yields a new MGRSGrid. Iterating yields every grid square in turn.
Parameters
filter_geometry: GeoSeries | GeoArray | BaseGeometry-
Area of interest in WGS84 (EPSG:4326). Every grid square intersecting it is included, whole. Accepts a single shapely geometry, an array of geometries, a
GeoSeries, or aGeoDataFrame. resolution: float = 10.0- Pixel size in metres for the MGRSGeoBox instances this grid yields. Must divide 10 km evenly, so a square is a whole number of pixels (10.0 m gives 1000 x 1000). Does not affect which squares are selected.
Raises
ValueError-
If
filter_geometrycarries a CRS other than WGS84.
See Also
- from_mgrs()
-
Build a single grid square from its MGRS reference.
Examples
>>> from shapely import box
>>> grid = MGRSGrid(box(8.4, 47.3, 8.6, 47.5)) # Zürich
>>> grid[0].mgrs_code # doctest: +SKIP‘32TMT97’
Methods
| Name | Description |
|---|---|
| __getitem__() | Return an MGRSGeoBox by index or a sliced MGRSGrid. |
| __iter__() | Iterate over all grid squares as MGRSGeoBox instances. |
| __len__() | Return the number of grid squares. |
| to_geodataframe() | Build a GeoDataFrame of the grid squares in WGS84. |
__getitem__()
Return an MGRSGeoBox by index or a sliced MGRSGrid.
Usage
__getitem__(self, index: int) -> MGRSGeoBox
__getitem__(self, index: slice) -> Self__iter__()
Iterate over all grid squares as MGRSGeoBox instances.
Usage
__iter__()__len__()
Return the number of grid squares.
Usage
__len__()to_geodataframe()
Build a GeoDataFrame of the grid squares in WGS84.
Usage
to_geodataframe()Returns
gpd.GeoDataFrame-
One row per grid square, in WGS84, with columns
mgrs_code,zone,hemisphere,easting,northing,epsg, andgeometry. Theepsgcolumn holds more than one value when the grid spans a UTM zone boundary.