Integration of Vgrid DGGS into Pandas and GeoPandas
Project description
VgridPandas
VgridPandas - Integrates Vgrid DGGS with GeoPandas and Pandas, inspired by H3-Pandas
VgridPandas supports a wide range of popular geodesic DGGS including H3, S2, A5, rHEALPix, Open-EAGGR ISEA4T, EASE-DGGS, DGGAL, DGGRID, QTM, as well as graticule-based DGGS such as OLC, Geohash, MGRS, GEOREF, TileCode, Quadkey, Maidenhead, and GARS.
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.
Installation
pip
pip install vgridpandas --upgrade
Key Features
- Latlong to DGGS: Convert latitude and longitude coordinates into DGGS cell IDs.
- DGGS to geo boundary: Convert DGGS cell IDs into their corresponding geographic boundaries.
- (Multi)Linestring/ (Multi)Polygon to DGGS: Convert (Multi)Linestring/ (Multi)Polygon to DGGS, supporting compact option.
- DGGS binning: Aggregate points into DGGS cells, supporting common statistics (count, min, max, etc.) and category-based groups.
Usage examples
Latlong to DGGS
import pandas as pd
from vgridpandas import h3pandas
df = pd.DataFrame({'lat': [10, 11], 'lon': [106, 107]})
resolution = 10
df = df.h3.latlon2h3(resolution)
df
| h3 | lat | lon |
|-----------------|-------|-------|
| 8a65a212199ffff | 10 | 106 |
| 8a65b0b68237fff | 11 | 107 |
DGGS to geo boundary
df = df.h3.h32geo()
df
| h3 | lat | lon | geometry |
|-----------------|-------|-------|-----------------|
| 8a65a212199ffff | 10 | 106 | POLYGON ((...)) |
| 8a65b0b68237fff | 11 | 107 | POLYGON ((...)) |
(Multi)Linestring/ (Multi)Polygon to DGGS
import geopandas as gpd
from vgridpandas import s2pandas
gdf = gpd.read_file('https://raw.githubusercontent.com/opengeoshub/vopendata/refs/heads/main/shape/polygon.geojson')
resolution = 18
gdf_polyfill = gdf.s2.polyfill(resolution, compact = True, predicate = "largest_overlap", explode = True)
gdf_polyfill.head()
gdf_polyfill = gdf_polyfill.s2.s22geo("s2")
gdf_polyfill.plot(edgecolor = "white")
DGGS Binning
import pandas as pd
import geopandas as gpd
from vgridpandas import a5pandas
resolution = 15
df = pd.read_csv("https://raw.githubusercontent.com/opengeoshub/vopendata/refs/heads/main/csv/dist1_pois.csv")
# df = gpd.read_file("https://raw.githubusercontent.com/opengeoshub/vopendata/refs/heads/main/shape/dist1_pois.geojson")
stats = "count"
df_bin = df.a5.a5bin(resolution=resolution, stats = stats,
# numeric_column="confidence",
# category_column="category",
return_geometry=True)
df_bin.plot(
column=stats, # numeric column to base the colors on
cmap='Spectral_r', # color scheme (matplotlib colormap)
legend=True,
linewidth=0.2 # boundary width (optional)
)
Further examples
For more examples, see the example notebooks.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vgridpandas-1.0.7.tar.gz.
File metadata
- Download URL: vgridpandas-1.0.7.tar.gz
- Upload date:
- Size: 1.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f7ebf9f44083f0dff8322a858bbda1b470f3ad86d1cfe4b23dfa875da4a8c19
|
|
| MD5 |
b9b54a26535029ca01aaaa60cdc79499
|
|
| BLAKE2b-256 |
655ac132c442d3d0838274f8ecef42c3da3c4ff94f506b93153d65faba9c7bed
|
File details
Details for the file vgridpandas-1.0.7-py3-none-any.whl.
File metadata
- Download URL: vgridpandas-1.0.7-py3-none-any.whl
- Upload date:
- Size: 108.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f371d0816bec99781c74e7a38904bda55973b399c8c5e40887d3a91092002f4
|
|
| MD5 |
75e758b7d8984821ea66027a2ce2fec3
|
|
| BLAKE2b-256 |
d66eacb4c9ce29b8fe5eacc0f1fbbe950d185fb59d834dcc5f7887993d66075a
|