09 dggrid
DGGRIDPandas key features¶
You can try out vgridpandas by using the cloud-computing platforms below without having to install anything on your computer:
Full VgridPandas DGGS documentation is available at vgridpandas document.
To work with Vgrid in Python or CLI, use vgrid package. Full Vgrid DGGS documentation is available at vgrid 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.
Install vgridpandas¶
Uncomment the following line to install vgridpandas.
In [1]:
Copied!
# %pip install vgridpandas
# %pip install vgridpandas
Download a portable version of DGGRID and start a DGGRID instance¶
In [2]:
Copied!
from dggrid4py import tool, DGGRIDv7
dggrid_exec = tool.get_portable_executable(".")
dggrid_instance = DGGRIDv7(
executable=dggrid_exec,
working_dir=".",
capture_logs=False,
silent=True,
has_gdal=False,
tmp_geo_out_legacy=True,
debug=False,
)
from dggrid4py import tool, DGGRIDv7
dggrid_exec = tool.get_portable_executable(".")
dggrid_instance = DGGRIDv7(
executable=dggrid_exec,
working_dir=".",
capture_logs=False,
silent=True,
has_gdal=False,
tmp_geo_out_legacy=True,
debug=False,
)
Latlon to DGGRID¶
In [ ]:
Copied!
import pandas as pd
from vgridpandas import dggridpandas
df = pd.read_csv('https://github.com/uber-web/kepler.gl-data/raw/master/nyctrips/data.csv')
df = df.head(100)
df = df.rename({'pickup_longitude': 'lon', 'pickup_latitude': 'lat'}, axis=1)[['lon', 'lat', 'passenger_count']]
resolution = 18
dggs_type = "ISEA3H" # choose one from ['CUSTOM', 'SUPERFUND', 'PLANETRISK', 'ISEA3H', 'ISEA4H', 'ISEA4T', 'ISEA4D', 'ISEA43H', 'ISEA7H', 'IGEO7', 'FULLER3H', 'FULLER4H', 'FULLER4T', 'FULLER4D', 'FULLER43H', 'FULLER7H']
address_type = "SEQNUM"
# "Q2DI", # quad number and (i, j) coordinates on that quad
# "SEQNUM", # DGGS index - linear address (1 to size-of-DGG), not supported for parameter input_address_type if dggs_aperture_type is SEQUENCE
# "PLANE", # (x, y) coordinates on unfolded ISEA plane, only supported for parameter output_address_type;
# "Q2DD", # quad number and (x, y) coordinates on that quad
# "PROJTRI", # PROJTRI - triangle number and (x, y) coordinates within that triangle on the ISEA plane
# "VERTEX2DD", # vertex number, triangle number, and (x, y) coordinates on ISEA plane
# "Z3", # hexadecimal characters index system Z3 especially usefull for ISEA3H
# "Z3_STRING", # numerical digits representation of Z3 (as characters, not an integer)
# "Z7", # hexadecimal characters index system Z7 especially usefull for ISEA7H, also in preset IGEO7
# "Z7_STRING", # numerical digits representation of Z7 (as characters, not an integer)
# "ZORDER", # index system ZORDER especially usefull for ISEA3H, ISEA4H and mixed aperture
# "ZORDER_STRING", # numerical digits representation of ZORDER (as characters, not an integer)
df = df.dggrid.latlon2dggrid(dggrid_instance,dggs_type, resolution,set_index=False, address_type=address_type)
df.head()
import pandas as pd
from vgridpandas import dggridpandas
df = pd.read_csv('https://github.com/uber-web/kepler.gl-data/raw/master/nyctrips/data.csv')
df = df.head(100)
df = df.rename({'pickup_longitude': 'lon', 'pickup_latitude': 'lat'}, axis=1)[['lon', 'lat', 'passenger_count']]
resolution = 18
dggs_type = "ISEA3H" # choose one from ['CUSTOM', 'SUPERFUND', 'PLANETRISK', 'ISEA3H', 'ISEA4H', 'ISEA4T', 'ISEA4D', 'ISEA43H', 'ISEA7H', 'IGEO7', 'FULLER3H', 'FULLER4H', 'FULLER4T', 'FULLER4D', 'FULLER43H', 'FULLER7H']
address_type = "SEQNUM"
# "Q2DI", # quad number and (i, j) coordinates on that quad
# "SEQNUM", # DGGS index - linear address (1 to size-of-DGG), not supported for parameter input_address_type if dggs_aperture_type is SEQUENCE
# "PLANE", # (x, y) coordinates on unfolded ISEA plane, only supported for parameter output_address_type;
# "Q2DD", # quad number and (x, y) coordinates on that quad
# "PROJTRI", # PROJTRI - triangle number and (x, y) coordinates within that triangle on the ISEA plane
# "VERTEX2DD", # vertex number, triangle number, and (x, y) coordinates on ISEA plane
# "Z3", # hexadecimal characters index system Z3 especially usefull for ISEA3H
# "Z3_STRING", # numerical digits representation of Z3 (as characters, not an integer)
# "Z7", # hexadecimal characters index system Z7 especially usefull for ISEA7H, also in preset IGEO7
# "Z7_STRING", # numerical digits representation of Z7 (as characters, not an integer)
# "ZORDER", # index system ZORDER especially usefull for ISEA3H, ISEA4H and mixed aperture
# "ZORDER_STRING", # numerical digits representation of ZORDER (as characters, not an integer)
df = df.dggrid.latlon2dggrid(dggrid_instance,dggs_type, resolution,set_index=False, address_type=address_type)
df.head()
DGGRID to geo boundary¶
In [ ]:
Copied!
df = df.dggrid.dggrid2geo(dggrid_instance, dggs_type, resolution)
df.head()
df = df.dggrid.dggrid2geo(dggrid_instance, dggs_type, resolution)
df.head()