13 georef
Working with GEOREF 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
latlon2georef¶
from vgrid.conversion.latlon2dggs import latlon2georef
lat = 10.775276
lon = 106.706797
res = 2
georef_id = latlon2georef(lat, lon, res)
georef_id
'VGBL4246'
GEOREF to Polygon¶
from vgrid.conversion.dggs2geo.georef2geo import georef2geo
from vgrid.dggs.georef import decode
georef_geo = georef2geo(georef_id)
georef_geo
GEOREF to GeoJSON¶
from vgrid.conversion.dggs2geo.georef2geo import georef2geojson
georef_geojson = georef2geojson(georef_id)
# georef_geojson
GEOREF Generator¶
from vgrid.generator.georefgrid import georefgrid
# georef_grid = georefgrid(resolution=1, output_format="geoparquet")
georef_grid = georefgrid(resolution=2,bbox=[104.03833902,8.53410125,111.92366325,12.80076792],output_format="parquet")
# georef_grid.plot(edgecolor="white")
Generating GEOREF DGGS: 100%|██████████| 121818/121818 [00:09<00:00, 13119.96 cells/s]
Output file saved as: d:\Github\vgrid\docs\notebooks\georef_grid_2.parquet
GEOREF Inspect¶
from vgrid.stats.georefstats import georefinspect
resolution = 1
georef_inspect = georefinspect(resolution)
georef_inspect.head()
Generating GEOREF DGGS: 100%|██████████| 64800/64800 [00:04<00:00, 13261.17 cells/s]
| georef | resolution | center_lat | center_lon | cell_width | cell_height | cell_area | cell_perimeter | geometry | crossed | norm_area | ipq | zsc | cvh | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | AAAA00 | 1 | -89.5 | -179.5 | 0.000000 | 111693.864914 | 1.088612e+08 | 225337.031822 | POLYGON ((-180 -90, -179 -90, -179 -89, -180 -... | False | 0.013830 | 0.026941 | 0.164138 | 1.0 |
| 1 | AAAB00 | 1 | -88.5 | -179.5 | 1949.301993 | 111693.177216 | 3.265476e+08 | 229233.654684 | POLYGON ((-180 -89, -179 -89, -179 -88, -180 -... | False | 0.041485 | 0.078091 | 0.279447 | 1.0 |
| 2 | AAAC00 | 1 | -87.5 | -179.5 | 3897.998258 | 111691.802680 | 5.441267e+08 | 233127.086900 | POLYGON ((-180 -88, -179 -88, -179 -87, -180 -... | False | 0.069127 | 0.125813 | 0.354701 | 1.0 |
| 3 | AAAD00 | 1 | -86.5 | -179.5 | 5845.483282 | 111689.743022 | 7.615267e+08 | 237016.121318 | POLYGON ((-180 -87, -179 -87, -179 -86, -180 -... | False | 0.096746 | 0.170349 | 0.412733 | 1.0 |
| 4 | AAAE00 | 1 | -85.5 | -179.5 | 7791.151992 | 111687.000814 | 9.786761e+08 | 240899.553582 | POLYGON ((-180 -86, -179 -86, -179 -85, -180 -... | False | 0.124333 | 0.211922 | 0.460350 | 1.0 |
GEOREF Normalized Area Histogram¶
from vgrid.stats.georefstats import georef_norm_area_hist
georef_norm_area_hist(georef_inspect)
Distribution of GEOREF Area Distortions¶
from vgrid.stats.georefstats import georef_norm_area
georef_norm_area(georef_inspect)
GEOREF 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.georefstats import georef_compactness_ipq_hist
georef_compactness_ipq_hist(georef_inspect)
Distribution of GEOREF IPQ Compactness¶
from vgrid.stats.georefstats import georef_compactness_ipq
georef_compactness_ipq(georef_inspect)
GEOREF 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.georefstats import georef_compactness_cvh_hist
georef_compactness_cvh_hist(georef_inspect)
Distribution of GEOREF Convex hull Compactness¶
from vgrid.stats.georefstats import georef_compactness_cvh
georef_compactness_cvh(georef_inspect)
GEOREF 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 georefstats
georefstats("m")
| resolution | number_of_cells | avg_edge_len_m | avg_cell_area_m2 | cls_m | |
|---|---|---|---|---|---|
| 0 | 0 | 288 | 1.330812e+06 | 1.771061e+12 | 1.502531e+06 |
| 1 | 1 | 64800 | 8.872082e+04 | 7.871383e+09 | 1.001110e+05 |
| 2 | 2 | 233280000 | 1.478680e+03 | 2.186495e+06 | 1.668512e+03 |
| 3 | 3 | 23328000000 | 1.478680e+02 | 2.186495e+04 | 1.668512e+02 |
| 4 | 4 | 2332800000000 | 1.478680e+01 | 2.186495e+02 | 1.668512e+01 |
| 5 | 5 | 233280000000000 | 1.478680e+00 | 2.186495e+00 | 1.668512e+00 |
| 6 | 6 | 23328000000000000 | 1.478680e-01 | 2.186495e-02 | 1.668512e-01 |
| 7 | 7 | 233280000000000000000 | 1.478680e-03 | 2.186495e-06 | 1.668512e-03 |
| 8 | 8 | 23328000000000000000000 | 1.478680e-04 | 2.186495e-08 | 1.668512e-04 |
| 9 | 9 | 233280000000000000000000000 | 1.478680e-06 | 2.186495e-12 | 1.668512e-06 |
| 10 | 10 | 23328000000000000000000000000 | 1.478680e-07 | 2.186495e-14 | 1.668512e-07 |