17 maidenhead
Working with Maidenhead in Vgrid DGGS¶
Full Vgrid DGGS documentation is available at vgrid document.
To work with Vgrid DGGS directly in GeoPandas and Pandas, please use vgridpandas. Full Vgridpandas DGGS documentation is available at vgridpandas document.
To work with Vgrid DGGS in QGIS, install the Vgrid Plugin.
To visualize DGGS in Maplibre GL JS, try the vgrid-maplibre library.
For an interactive demo, visit the Vgrid Homepage.
# %pip install vgrid --upgrade
latlon2maidenhead¶
from vgrid.conversion.latlon2dggs import latlon2maidenhead
lat = 10.775276
lon = 106.706797
res = 3
maidenhead_id = latlon2maidenhead(lat, lon, res)
maidenhead_id
'OK30is'
Maidenhead to Polygon¶
from vgrid.conversion.dggs2geo.maidenhead2geo import maidenhead2geo
maidenhead_geo = maidenhead2geo(maidenhead_id)
maidenhead_geo
Maidenhead to GeoJSON¶
from vgrid.conversion.dggs2geo.maidenhead2geo import maidenhead2geojson
maidenhead_geojson = maidenhead2geojson(maidenhead_id)
# maidenhead_geojson
Maidenhead Generator¶
from vgrid.generator.maidenheadgrid import maidenheadgrid
maidenhead_grid = maidenheadgrid(resolution=2, output_format="gpd")
# maidenhead_grid = maidenheadgrid(resolution=3,bbox=[102.14,7.69,114.86,23.39],output_format="gpd")
maidenhead_grid.plot(edgecolor="#3474eb", facecolor="none", linewidth=0.1)
Generating Maidenhead DGGS: 93%|█████████▎| 30039/32400 [00:07<00:00, 2848.99 cells/s]
Generating Maidenhead DGGS: 100%|██████████| 32400/32400 [00:09<00:00, 3506.94 cells/s]
<Axes: >
Maidenhead Inspect¶
from vgrid.stats.maidenheadstats import maidenheadinspect
resolution = 2
maidenhead_inspect = maidenheadinspect(resolution)
maidenhead_inspect.head()
Generating Maidenhead DGGS: 100%|██████████| 32400/32400 [00:02<00:00, 14660.20 cells/s]
| maidenhead | resolution | center_lat | center_lon | cell_width | cell_height | cell_area | cell_perimeter | geometry | crossed | norm_area | ipq | zsc | cvh | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | AA00 | 2 | -89.5 | -179.0 | 0.000000 | 111693.864914 | 2.176892e+08 | 227286.185413 | POLYGON ((-180 -90, -178 -90, -178 -89, -180 -... | False | 0.013828 | 0.052954 | 0.230118 | 1.0 |
| 1 | AA01 | 2 | -88.5 | -179.0 | 3898.455585 | 111693.177216 | 6.529959e+08 | 235080.510047 | POLYGON ((-180 -89, -178 -89, -178 -88, -180 -... | False | 0.041479 | 0.148487 | 0.385339 | 1.0 |
| 2 | AA02 | 2 | -87.5 | -179.0 | 7795.700029 | 111691.802680 | 1.088088e+09 | 242869.828017 | POLYGON ((-180 -88, -178 -88, -178 -87, -180 -... | False | 0.069117 | 0.231807 | 0.481463 | 1.0 |
| 3 | AA03 | 2 | -86.5 | -179.0 | 11690.522628 | 111689.743022 | 1.522823e+09 | 250651.722215 | POLYGON ((-180 -87, -178 -87, -178 -86, -180 -... | False | 0.096732 | 0.304592 | 0.551897 | 1.0 |
| 4 | AA04 | 2 | -85.5 | -179.0 | 15581.713544 | 111687.000814 | 1.957057e+09 | 258423.779413 | POLYGON ((-180 -86, -178 -86, -178 -85, -180 -... | False | 0.124315 | 0.368255 | 0.606839 | 1.0 |
Maidenhead Normalized Area Histogram¶
from vgrid.stats.maidenheadstats import maidenhead_norm_area_hist
maidenhead_norm_area_hist(maidenhead_inspect)
Distribution of Maidenhead Area Distortions¶
from vgrid.stats.maidenheadstats import maidenhead_norm_area
maidenhead_norm_area(maidenhead_inspect)
Maidenhead IPQ Compactness Histogram¶
Isoperimetric Inequality (IPQ) Compactness (suggested by Osserman, 1978):
$$C_{IPQ} = \frac{4 \pi A}{p^2}$$ The range of the IPQ compactness metric is [0,1].
A circle represents the maximum compactness with a value of 1.
As shapes become more irregular or elongated, their compactness decreases toward 0.
from vgrid.stats.maidenheadstats import maidenhead_compactness_ipq_hist
maidenhead_compactness_ipq_hist(maidenhead_inspect)
Distribution of Maidenhead IPQ Compactness¶
from vgrid.stats.maidenheadstats import maidenhead_compactness_ipq
maidenhead_compactness_ipq(maidenhead_inspect)
Maidenhead Convex hull Compactness Histogram:¶
$$C_{CVH} = \frac{A}{A_{CVH}}$$
The range of the convex hull compactness metric is [0,1].
As shapes become more concave, their convex hull compactness decreases toward 0.
from vgrid.stats.maidenheadstats import maidenhead_compactness_cvh_hist
maidenhead_compactness_cvh_hist(maidenhead_inspect)
Distribution of Maidenhaed Convex hull Compactness¶
from vgrid.stats.maidenheadstats import maidenhead_compactness_cvh
maidenhead_compactness_cvh(maidenhead_inspect)
Maidenhead Statistics¶
Characteristic Length Scale (CLS - suggested by Ralph Kahn): the diameter of a spherical cap of the same cell's area
from vgrid.stats import maidenheadstats
maidenheadstats("km")
| resolution | number_of_cells | avg_edge_len_km | avg_cell_area_km2 | cls_km | |
|---|---|---|---|---|---|
| 0 | 1 | 324 | 1254.701801 | 1.574277e+06 | 1416.508668 |
| 1 | 2 | 32400 | 125.470180 | 1.574277e+04 | 141.578666 |
| 2 | 3 | 18662400 | 5.227924 | 2.733119e+01 | 5.899081 |
| 3 | 4 | 1866240000 | 0.522792 | 2.733119e-01 | 0.589908 |