Visualize the Military Grid Reference System (MGRS)
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# %pip install "leafmap[maplibre]"
# %pip install "leafmap[maplibre]"
In [2]:
Copied!
import leafmap.maplibregl as leafmap
import leafmap.maplibregl as leafmap
In [3]:
Copied!
m = leafmap.Map(style="positron", projection="globe")
m.add_basemap("Satellite")
geojson = "https://github.com/opengeos/datasets/releases/download/world/mgrs_grid_zone.geojson"
m.add_geojson(geojson)
m.add_labels(geojson, "GZD", text_color="white", min_zoom=2, max_zoom=10)
m
m = leafmap.Map(style="positron", projection="globe")
m.add_basemap("Satellite")
geojson = "https://github.com/opengeos/datasets/releases/download/world/mgrs_grid_zone.geojson"
m.add_geojson(geojson)
m.add_labels(geojson, "GZD", text_color="white", min_zoom=2, max_zoom=10)
m
In [4]:
Copied!
m = leafmap.Map(style="positron", projection="globe")
m.add_basemap("Satellite")
geojson = "https://github.com/opengeos/datasets/releases/download/world/mgrs_grid_zone.geojson"
paint = {"line-color": "red"}
pmtiles = (
"https://huggingface.co/datasets/giswqs/geospatial/resolve/main/MGRS_100km.pmtiles"
)
fill_style = {
"layers": [
{
"id": "MGRS_100km_fill",
"source": "MGRS_100km",
"source-layer": "MGRS_100km",
"type": "fill",
"paint": {
"fill-opacity": 0,
"fill-color": "white",
"fill-outline-color": "#ffffff",
},
"min-zoom": 3,
},
]
}
line_style = {
"layers": [
{
"id": "MGRS_100km_line",
"source": "MGRS_100km_line",
"source-layer": "MGRS_100km",
"type": "line",
"paint": {
"line-color": "white",
},
"min-zoom": 3,
},
]
}
m.add_pmtiles(pmtiles, style=fill_style, tooltip=True, fit_bounds=False)
m.add_pmtiles(pmtiles, style=line_style, tooltip=False, fit_bounds=False)
m.add_geojson(geojson, layer_type="line", paint=paint)
m.add_labels(geojson, "GZD", text_color="white", min_zoom=2)
m
m = leafmap.Map(style="positron", projection="globe")
m.add_basemap("Satellite")
geojson = "https://github.com/opengeos/datasets/releases/download/world/mgrs_grid_zone.geojson"
paint = {"line-color": "red"}
pmtiles = (
"https://huggingface.co/datasets/giswqs/geospatial/resolve/main/MGRS_100km.pmtiles"
)
fill_style = {
"layers": [
{
"id": "MGRS_100km_fill",
"source": "MGRS_100km",
"source-layer": "MGRS_100km",
"type": "fill",
"paint": {
"fill-opacity": 0,
"fill-color": "white",
"fill-outline-color": "#ffffff",
},
"min-zoom": 3,
},
]
}
line_style = {
"layers": [
{
"id": "MGRS_100km_line",
"source": "MGRS_100km_line",
"source-layer": "MGRS_100km",
"type": "line",
"paint": {
"line-color": "white",
},
"min-zoom": 3,
},
]
}
m.add_pmtiles(pmtiles, style=fill_style, tooltip=True, fit_bounds=False)
m.add_pmtiles(pmtiles, style=line_style, tooltip=False, fit_bounds=False)
m.add_geojson(geojson, layer_type="line", paint=paint)
m.add_labels(geojson, "GZD", text_color="white", min_zoom=2)
m