## mgrs.MGRSGrid


The 10 km MGRS grid squares covering an area of interest.


Usage

``` python
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](mgrs.MGRSGeoBox.md#freezebase.mgrs.MGRSGeoBox); slicing yields a new [MGRSGrid](mgrs.MGRSGrid.md#freezebase.mgrs.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 a `GeoDataFrame`.

`resolution: float = ``10.0`  
Pixel size in metres for the [MGRSGeoBox](mgrs.MGRSGeoBox.md#freezebase.mgrs.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_geometry` carries a CRS other than WGS84.


## See Also

[from_mgrs()](mgrs.MGRSGeoBox.md#freezebase.mgrs.MGRSGeoBox.from_mgrs)  
Build a single grid square from its MGRS reference.


## Examples

``` python
>>> 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__()](#__getitem__) | Return an MGRSGeoBox by index or a sliced MGRSGrid. |
| [__iter__()](#__iter__) | Iterate over all grid squares as MGRSGeoBox instances. |
| [__len__()](#__len__) | Return the number of grid squares. |
| [to_geodataframe()](#to_geodataframe) | Build a GeoDataFrame of the grid squares in WGS84. |

------------------------------------------------------------------------


#### \_\_getitem\_\_()


Return an MGRSGeoBox by index or a sliced MGRSGrid.


Usage

``` python
__getitem__(self, index: int) -> MGRSGeoBox
__getitem__(self, index: slice) -> Self
```


------------------------------------------------------------------------


#### \_\_iter\_\_()


Iterate over all grid squares as MGRSGeoBox instances.


Usage

``` python
__iter__()
```


------------------------------------------------------------------------


#### \_\_len\_\_()


Return the number of grid squares.


Usage

``` python
__len__()
```


------------------------------------------------------------------------


#### to_geodataframe()


Build a GeoDataFrame of the grid squares in WGS84.


Usage

``` python
to_geodataframe()
```


##### Returns


`gpd.GeoDataFrame`  
One row per grid square, in WGS84, with columns `mgrs_code`, `zone`, `hemisphere`, `easting`, `northing`, `epsg`, and `geometry`. The `epsg` column holds more than one value when the grid spans a UTM zone boundary.
