18 gars
Working with GARS 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
latlon2gars¶
from vgrid.conversion.latlon2dggs import latlon2gars
lat = 10.775276
lon = 106.706797
res = 3
gars_id = latlon2gars(lat, lon, res)
gars_id
'574JK19'
GARS to Polygon¶
from vgrid.conversion.dggs2geo.gars2geo import gars2geo
gars_geo = gars2geo(gars_id)
gars_geo
GARS to GeoJSON¶
from vgrid.conversion.dggs2geo.gars2geo import gars2geojson
gars_geojson = gars2geojson(gars_id)
# gars_geojson
GARS Generator¶
from vgrid.generator.garsgrid import garsgrid
gars_grid = garsgrid(
resolution=4,
bbox=[106.50410038, 10.68281767, 106.88230310, 10.82281670],
output_format="geoparquet",
)
# gars_grid.plot(edgecolor="white")
Generating GARS DGGS: 100%|██████████| 207/207 [00:00<00:00, 4712.42 cells/s]
Output file saved as: d:\Github\vgrid\docs\notebooks\gars_grid_4.parquet
GARS Inspect¶
from vgrid.stats.garsstats import garsinspect
resolution = 1
gars_inspect = garsinspect(resolution)
gars_inspect.head()
Generating GARS DGGS: 100%|██████████| 259200/259200 [00:29<00:00, 8664.08 cells/s]
| gars | resolution | center_lat | center_lon | cell_width | cell_height | cell_area | cell_perimeter | geometry | crossed | norm_area | ipq | zsc | cvh | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 001AA | 1 | -89.75 | -179.75 | 0.000000 | 55846.975448 | 1.360844e+07 | 112181.299964 | POLYGON ((-179.5 -90, -179.5 -89.5, -180 -89.5... | False | 0.006915 | 0.013589 | 0.116571 | 1.0 |
| 1 | 001AB | 1 | -89.25 | -179.75 | 487.349067 | 55846.889466 | 4.082421e+07 | 113155.788271 | POLYGON ((-179.5 -89.5, -179.5 -89, -180 -89, ... | False | 0.020746 | 0.040066 | 0.200164 | 1.0 |
| 2 | 001AC | 1 | -88.75 | -179.75 | 974.660272 | 55846.717528 | 6.803661e+07 | 114129.991081 | POLYGON ((-179.5 -89, -179.5 -88.5, -180 -88.5... | False | 0.034574 | 0.065638 | 0.256198 | 1.0 |
| 3 | 001AD | 1 | -88.25 | -179.75 | 1461.895753 | 55846.459688 | 9.524342e+07 | 115103.832790 | POLYGON ((-179.5 -88.5, -179.5 -88, -180 -88, ... | False | 0.048400 | 0.090337 | 0.300561 | 1.0 |
| 4 | 001AE | 1 | -87.75 | -179.75 | 1949.017659 | 55846.116027 | 1.224424e+08 | 116077.237862 | POLYGON ((-179.5 -88, -179.5 -87.5, -180 -87.5... | False | 0.062222 | 0.114195 | 0.337928 | 1.0 |
GARS Normalized Area Histogram¶
from vgrid.stats.garsstats import gars_norm_area_hist
gars_norm_area_hist(gars_inspect)
Distribution of GARS Area Distortions¶
from vgrid.stats.garsstats import gars_norm_area
gars_norm_area(gars_inspect)
GARS 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.garsstats import gars_compactness_ipq_hist
gars_compactness_ipq_hist(gars_inspect)
Distribution of GARS IPQ Compactness¶
from vgrid.stats.garsstats import gars_compactness_ipq
gars_compactness_ipq(gars_inspect)
GARS 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.garsstats import gars_compactness_cvh_hist
gars_compactness_cvh_hist(gars_inspect)
Distribution of GARS Convex hull Compactness¶
from vgrid.stats.garsstats import gars_compactness_cvh
gars_compactness_cvh(gars_inspect)
GARS 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 garsstats
garsstats("km")
| resolution | number_of_cells | avg_edge_len_km | avg_cell_area_km2 | cls_km | |
|---|---|---|---|---|---|
| 0 | 1 | 259200 | 44.360408 | 1967.845763 | 50.055392 |
| 1 | 2 | 1036800 | 22.180204 | 491.961441 | 25.027684 |
| 2 | 3 | 9331200 | 7.393401 | 54.662382 | 8.342560 |
| 3 | 4 | 233280000 | 1.478680 | 2.186495 | 1.668512 |