06 isea3h
ISEA3HPandas 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
Latlon to OpenEAGGR ISEA3H¶
In [2]:
Copied!
import pandas as pd
from vgridpandas import isea3hpandas
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 = 16
df = df.isea3h.latlon2isea3h(resolution)
df.head()
import pandas as pd
from vgridpandas import isea3hpandas
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 = 16
df = df.isea3h.latlon2isea3h(resolution)
df.head()
Out[2]:
| lon | lat | passenger_count | isea3h | isea3h_res | |
|---|---|---|---|---|---|
| 0 | -73.993896 | 40.750111 | 1 | 0116-1266,-151 | 16 |
| 1 | -73.976425 | 40.739811 | 1 | 0116-1267,-150 | 16 |
| 2 | -73.968704 | 40.754246 | 5 | 0116-1265,-150 | 16 |
| 3 | -73.863060 | 40.769581 | 5 | 0116-1264,-141 | 16 |
| 4 | -73.945541 | 40.779423 | 1 | 0116-1263,-148 | 16 |
OpenEAGGR ISEA3H to geo boundary¶
In [3]:
Copied!
df = df.isea3h.isea3h2geo()
df.head()
df = df.isea3h.isea3h2geo()
df.head()
Out[3]:
| lon | lat | passenger_count | isea3h | isea3h_res | geometry | |
|---|---|---|---|---|---|---|
| 0 | -73.993896 | 40.750111 | 1 | 0116-1266,-151 | 16 | POLYGON ((-73.98575 40.74841, -73.99244 40.751... |
| 1 | -73.976425 | 40.739811 | 1 | 0116-1267,-150 | 16 | POLYGON ((-73.96567 40.73905, -73.97236 40.742... |
| 2 | -73.968704 | 40.754246 | 5 | 0116-1265,-150 | 16 | POLYGON ((-73.96627 40.7582, -73.97296 40.7613... |
| 3 | -73.863060 | 40.769581 | 5 | 0116-1264,-141 | 16 | POLYGON ((-73.85444 40.76895, -73.86113 40.772... |
| 4 | -73.945541 | 40.779423 | 1 | 0116-1263,-148 | 16 | POLYGON ((-73.94048 40.77762, -73.94717 40.780... |
(Multi)Linestring/ (Multi)Polygon to ISEA3H¶
In [4]:
Copied!
from vgridpandas import isea3hpandas
import geopandas as gpd
gdf = gpd.read_file('https://raw.githubusercontent.com/opengeoshub/vopendata/refs/heads/main/shape/polygon.geojson')
resolution = 17
gdf_polyfill = gdf.isea3h.polyfill(resolution, compact = True, predicate = "intersects", explode = False)
gdf_polyfill = gdf_polyfill.isea3h.isea3h2geo(isea3h_column = "isea3h")
gdf_polyfill.plot(edgecolor = "white")
from vgridpandas import isea3hpandas
import geopandas as gpd
gdf = gpd.read_file('https://raw.githubusercontent.com/opengeoshub/vopendata/refs/heads/main/shape/polygon.geojson')
resolution = 17
gdf_polyfill = gdf.isea3h.polyfill(resolution, compact = True, predicate = "intersects", explode = False)
gdf_polyfill = gdf_polyfill.isea3h.isea3h2geo(isea3h_column = "isea3h")
gdf_polyfill.plot(edgecolor = "white")
Out[4]:
<Axes: >
ISEA3H point binning¶
In [5]:
Copied!
import pandas as pd
import geopandas as gpd
from vgridpandas import isea3hpandas
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.isea3h.isea3hbin(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)
)
import pandas as pd
import geopandas as gpd
from vgridpandas import isea3hpandas
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.isea3h.isea3hbin(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)
)
Out[5]:
<Axes: >