Skip to main content

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, QTM, as well as graticule-based DGGS such as OLC, Geohash, MGRS, GEOREF, TileCode, Quadkey, Maidenhead, and GARS.

logo

image image image image PyPI version image image

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

image

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

vgridpandas-1.0.6.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vgridpandas-1.0.6-py3-none-any.whl (91.1 kB view details)

Uploaded Python 3

File details

Details for the file vgridpandas-1.0.6.tar.gz.

File metadata

  • Download URL: vgridpandas-1.0.6.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.12

File hashes

Hashes for vgridpandas-1.0.6.tar.gz
Algorithm Hash digest
SHA256 70b425a2d4f388dc6a2bee64189be3501d5eef10532990fd3c9ec6fe273f3eb3
MD5 57530d01db43405b32cab7b3d6e56b25
BLAKE2b-256 dfb51e8844021846bbbc344190037f61fc6fa932bbdd4d1f96d33373583057ea

See more details on using hashes here.

File details

Details for the file vgridpandas-1.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for vgridpandas-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0526fc4ebe012c72abaf990c2fb81d8b82e0fe9dbe254903e8479d4279053c80
MD5 75fc12a7a253e9969931be88a43a1c97
BLAKE2b-256 08a90c1b03760d5da72368a5c0932bf019d2f04e966e6f5edaa1f9b50ef00a84

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page