s2d2.handler.mgrs

Module Contents

Functions

_kml_to_gdf(tile_path)

Read MGRS kml file as a GeoPandas DataFrame, keep only polygon geometries.

_get_mgrs_abc()

_mgrs_to_search_geometry(tile_code)

Get a geometry from the tile code. The search geometry is a 6-deg longitude

get_mgrs_tile(lat, lon)

return a military grid reference system zone designation string.

get_geom_from_tile_code(tile_code[, tile_path])

Get the geometry of a certain MGRS tile

get_tile_codes_from_geom(geom[, tile_path])

Get the codes of the MGRS tiles intersecting a given geometry

get_bbox_from_tile_code(tile_code[, tile_path])

Get the bounds of a certain MGRS tile

Attributes

MGRS_TILING_URL

MGRS_TILING_FILENAME

MGRS_TILING_DIR_DEFAULT

s2d2.handler.mgrs.MGRS_TILING_URL = 'https://sentinels.copernicus.eu/documents/247904/1955685/S2A_OPER_GIP_TILPAR_MPC__20151209T095117...'[source]
s2d2.handler.mgrs.MGRS_TILING_FILENAME = 'sentinel2_tiles_world.geojson'[source]
s2d2.handler.mgrs.MGRS_TILING_DIR_DEFAULT[source]
s2d2.handler.mgrs._kml_to_gdf(tile_path)[source]

Read MGRS kml file as a GeoPandas DataFrame, keep only polygon geometries.

Parameters:

tile_path (str) – kml file name

Returns:

KML file read as a GeoDataFrame

Return type:

geopandas.geodataframe.GeoDataFrame

s2d2.handler.mgrs._get_mgrs_abc()[source]
s2d2.handler.mgrs._mgrs_to_search_geometry(tile_code)[source]

Get a geometry from the tile code. The search geometry is a 6-deg longitude stripe, augmented with the stripe across the antimeridian for the tiles that are crossing this line.

Parameters:

tile_code (str) – MGRS code of the tile

Returns:

geometry to restrict the search area

Return type:

shapely.Geometry

s2d2.handler.mgrs.get_mgrs_tile(lat, lon)[source]

return a military grid reference system zone designation string. This zoning is used in the tiling of Sentinel-2.

Parameters:
  • lat (float, unit=degrees, range=-90...+90) – latitude

  • lon (float, unit=degrees) – longitude

Returns:

mgrs_code

Return type:

string

Notes

The MGRS tile structure is a follows “AABCC”
  • “AA” utm zone number, starting from the East, with steps of 8 degrees

  • “B” latitude zone, starting from the South, with steps of 6 degrees

  • “CC” 100 km square identifier

The following acronyms are used:
  • CRS : coordinate reference system

  • MGRS : US military grid reference system

  • WKT : well known text

  • UTM: universal transverse mercator projection

s2d2.handler.mgrs.get_geom_from_tile_code(tile_code, tile_path=None)[source]

Get the geometry of a certain MGRS tile

Parameters:
  • tile_code (string) – MGRS tile coding, e.g.: ‘05VMG’

  • tile_path (string) – Path to the geometric metadata

Returns:

Geometry of the MGRS tile, in lat/lon

Return type:

shapely.geometry.polygon.Polygon

See also

get_tile_code_from_geom, get_bbox_from_tile_code

s2d2.handler.mgrs.get_tile_codes_from_geom(geom, tile_path=None)[source]

Get the codes of the MGRS tiles intersecting a given geometry

Parameters:
  • geom ({shapely.geometry, string, dict, GeoDataFrame, GeoSeries}) – geometry object with the given dict-like geojson geometry, GeoSeries, GeoDataFrame, shapely geometry or well known text, i.e.: ‘POLYGON ((x y, x y, x y))’

  • tile_path (string) – Path to the geometric metadata

Returns:

MGRS tile codes

Return type:

tuple

s2d2.handler.mgrs.get_bbox_from_tile_code(tile_code, tile_path=None)[source]

Get the bounds of a certain MGRS tile

Parameters:
  • tile_code (string, e.g.: '05VMG') – MGRS tile coding

  • tile_path (string) – Path to the geometric metadata

Returns:

bounding box, in the following order: min max X, min max Y

Return type:

numpy.ndarray, size=(1,4), dtype=float