Integration of DGGS and GeoPandas
Project description
VgridPandas
Integrates vgrid with GeoPandas and Pandas, inspired by H3-Pandas
⬢ Try it out ⬢
Installation
pip
pip install vgridpandas
conda
conda install -c conda-forge vgridpandas
Usage examples
H3 API
vgiridpandas.h3pandas automatically applies H3 functions to both Pandas Dataframes and GeoPandas Geodataframes
# Prepare data
>>> import pandas as pd
>>> from vgridpandas import h3pandas
>>> df = pd.DataFrame({'lat': [50, 51], 'lng': [14, 15]})
>>> resolution = 10
>>> df = df.h3.latlon2h3(resolution)
>>> df
| h3_10 | lat | lng |
|:----------------|------:|------:|
| 8a1e30973807fff | 50 | 14 |
| 8a1e2659c2c7fff | 51 | 15 |
>>> df = df.h3.h3_to_geo_boundary()
>>> df
| h3_10 | lat | lng | geometry |
|:----------------|------:|------:|:----------------|
| 8a1e30973807fff | 50 | 14 | POLYGON ((...)) |
| 8a1e2659c2c7fff | 51 | 15 | POLYGON ((...)) |
VgridPandas Extended API
h3pandas also provides some extended functionality out-of-the-box,
often simplifying common workflows into a single command.
# Set up data
>>> import numpy as np
>>> import pandas as pd
>>> np.random.seed(1729)
>>> df = pd.DataFrame({
>>> 'lat': np.random.uniform(50, 51, 100),
>>> 'lng': np.random.uniform(14, 15, 100),
>>> 'value': np.random.poisson(100, 100)})
>>> })
# Aggregate values by their location and sum
>>> df = df.h3.geo_to_h3_aggregate(3)
>>> df
| h3_03 | value | geometry |
|:----------------|--------:|:----------------|
| 831e30fffffffff | 102 | POLYGON ((...)) |
| 831e34fffffffff | 189 | POLYGON ((...)) |
| 831e35fffffffff | 8744 | POLYGON ((...)) |
| 831f1bfffffffff | 1040 | POLYGON ((...)) |
# Aggregate to a lower H3 resolution
>>> df.h3.h3_to_parent_aggregate(2)
| h3_02 | value | geometry |
|:----------------|--------:|:----------------|
| 821e37fffffffff | 9035 | POLYGON ((...)) |
| 821f1ffffffffff | 1040 | POLYGON ((...)) |
Further examples
For more examples, see the example notebooks.
API
For a full API documentation and more usage examples, see the documentation.
Any suggestions and contributions are very welcome!
See issues for more.
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.0.tar.gz.
File metadata
- Download URL: vgridpandas-1.0.0.tar.gz
- Upload date:
- Size: 457.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13a54602276bb9e8e551389f18410361daa27421403ed1ec4c9593a152d2b634
|
|
| MD5 |
5d2ae60e1ef38c8fd0a7e86dae059c1a
|
|
| BLAKE2b-256 |
9ce6e277310e7cb23287d965045cebd4d038902ae879b4e9ca3a8f94f304f507
|
File details
Details for the file vgridpandas-1.0.0-py3-none-any.whl.
File metadata
- Download URL: vgridpandas-1.0.0-py3-none-any.whl
- Upload date:
- Size: 516.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60c6b2d915caf50dfe82b1414544744cc385cc2a7768a8f9660d1128bccbe7c4
|
|
| MD5 |
af5f19360ac10d90e476e4bb669ba518
|
|
| BLAKE2b-256 |
86c1f5d4a69b79318b0c1b84a483200131ea30dba80acbe8c9cba4cc11ebc80b
|