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.
In [1]:
Copied!
# %pip install vgrid --upgrade
# %pip install vgrid --upgrade
latlon2gars¶
In [2]:
Copied!
from vgrid.conversion.latlon2dggs import latlon2gars
lat = 10.775276
lon = 106.706797
res = 3
gars_id = latlon2gars(lat, lon, res)
gars_id
from vgrid.conversion.latlon2dggs import latlon2gars
lat = 10.775276
lon = 106.706797
res = 3
gars_id = latlon2gars(lat, lon, res)
gars_id
Out[2]:
'574JK19'
GARS to Shapely Polygon¶
In [3]:
Copied!
from vgrid.conversion.dggs2geo.gars2geo import gars2geo
gars_geo = gars2geo(gars_id)
gars_geo
from vgrid.conversion.dggs2geo.gars2geo import gars2geo
gars_geo = gars2geo(gars_id)
gars_geo
Out[3]:
GARS to GeoJSON¶
In [4]:
Copied!
from vgrid.conversion.dggs2geo.gars2geo import gars2geojson
gars_geojson = gars2geojson(gars_id)
gars_geojson
from vgrid.conversion.dggs2geo.gars2geo import gars2geojson
gars_geojson = gars2geojson(gars_id)
gars_geojson
Out[4]:
{'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': (((106.75, 10.75), (106.75, 10.833333333333334), (106.66666666666667, 10.833333333333334), (106.66666666666667, 10.75), (106.75, 10.75)),)}, 'properties': {'gars': '574JK19', 'resolution': 3, 'center_lat': 10.7916667, 'center_lon': 106.7083333, 'cell_width': 9114.885, 'cell_height': 9217.768, 'cell_area': 84007349.416, 'cell_perimeter': 36662.795}}]}
GARS Generator¶
In [5]:
Copied!
from vgrid.generator.garsgrid import garsgrid
gars_grid = garsgrid(resolution=4,bbox=[106.699007, 10.762811, 106.717674, 10.778649],output_format="gpd")
gars_grid.plot(edgecolor="white")
from vgrid.generator.garsgrid import garsgrid
gars_grid = garsgrid(resolution=4,bbox=[106.699007, 10.762811, 106.717674, 10.778649],output_format="gpd")
gars_grid.plot(edgecolor="white")
Generating GARS DGGS: 6 cells [00:00, 2379.75 cells/s]
Out[5]:
<Axes: >
GARS Inspect¶
In [6]:
Copied!
from vgrid.stats.garsstats import garsinspect
resolution = 1
gars_inspect = garsinspect(resolution)
gars_inspect.head()
from vgrid.stats.garsstats import garsinspect
resolution = 1
gars_inspect = garsinspect(resolution)
gars_inspect.head()
Generating GARS DGGS: 100%|██████████| 259200/259200 [00:38<00:00, 6767.27 cells/s]
Out[6]:
gars | resolution | center_lat | center_lon | cell_width | cell_height | cell_area | cell_perimeter | geometry | crossed | norm_area | ipq | zsc | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 001AA | 1 | -89.75 | -179.75 | 0.000 | 55846.975 | 1.360844e+07 | 112181.300 | POLYGON ((-179.5 -90, -179.5 -89.5, -180 -89.5... | False | 0.006915 | 0.013589 | 0.116571 |
1 | 001AB | 1 | -89.25 | -179.75 | 487.349 | 55846.889 | 4.082421e+07 | 113155.788 | POLYGON ((-179.5 -89.5, -179.5 -89, -180 -89, ... | False | 0.020746 | 0.040066 | 0.200164 |
2 | 001AC | 1 | -88.75 | -179.75 | 974.660 | 55846.718 | 6.803661e+07 | 114129.991 | POLYGON ((-179.5 -89, -179.5 -88.5, -180 -88.5... | False | 0.034574 | 0.065638 | 0.256198 |
3 | 001AD | 1 | -88.25 | -179.75 | 1461.896 | 55846.460 | 9.524342e+07 | 115103.833 | POLYGON ((-179.5 -88.5, -179.5 -88, -180 -88, ... | False | 0.048400 | 0.090337 | 0.300561 |
4 | 001AE | 1 | -87.75 | -179.75 | 1949.018 | 55846.116 | 1.224424e+08 | 116077.238 | POLYGON ((-179.5 -88, -179.5 -87.5, -180 -87.5... | False | 0.062222 | 0.114195 | 0.337928 |
Distribution of GARS Area Distortions¶
In [7]:
Copied!
from vgrid.stats.garsstats import gars_norm_area
gars_norm_area(gars_inspect)
from vgrid.stats.garsstats import gars_norm_area
gars_norm_area(gars_inspect)
Distribution of GARS IPQ Compactness¶
In [8]:
Copied!
from vgrid.stats.garsstats import gars_compactness
gars_compactness(gars_inspect)
from vgrid.stats.garsstats import gars_compactness
gars_compactness(gars_inspect)
GARS Statistics¶
In [9]:
Copied!
from vgrid.stats import garsstats
garsstats('km')
from vgrid.stats import garsstats
garsstats('km')
Out[9]:
resolution | number_of_cells | avg_edge_len_km | avg_cell_area_km2 | |
---|---|---|---|---|
0 | 1 | 259200 | 44.360408 | 1967.845775 |
1 | 2 | 1036800 | 22.180204 | 491.961444 |
2 | 3 | 9331200 | 7.393401 | 54.662383 |
3 | 4 | 233280000 | 1.478680 | 2.186495 |