Skip to content

Latlon grid

image image image

Generate a lat-lon grid

Uncomment the following line to install leafmap if needed.

1
# %pip install leafmap
1
import leafmap.maplibregl as leafmap
1
2
3
4
extent = (-125, 24, -66, 50)
grid = leafmap.generate_latlon_grid(extent, dx=1, dy=1)
print(len(grid), "grid cells")
grid.head()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
m = leafmap.Map(center=[-100, 40], zoom=3, style="liberty")
m.add_gdf(
    grid,
    name="Grid",
    layer_type="fill",
    paint={
        "fill-color": "rgba(0, 0, 0, 0)",
        "fill-outline-color": "rgba(255, 0, 0, 255)",
    },
    fit_bounds=False,
)
m