06 ease
EASE-DGGS key features¶
You can try out vgridpandas by using the cloud-computing platforms below without having to install anything on your computer:
Install vgridpandas¶
In [1]:
Copied!
# %pip install vgridpandas
# %pip install vgridpandas
Latlong to EASE-DGGS¶
In [2]:
Copied!
import pandas as pd
from vgridpandas import easepandas
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 = 6
df = df.ease.latlon2ease(resolution)
df.head()
import pandas as pd
from vgridpandas import easepandas
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 = 6
df = df.ease.latlon2ease(resolution)
df.head()
Out[2]:
lon | lat | passenger_count | ease_res | |
---|---|---|---|---|
ease | ||||
L6.070283.13.01.20.89.78.88 | -73.993896 | 40.750111 | 1 | 6 |
L6.070283.13.11.02.86.77.82 | -73.976425 | 40.739811 | 1 | 6 |
L6.070283.13.02.20.44.71.66 | -73.968704 | 40.754246 | 5 | 6 |
L6.070284.10.02.01.96.80.71 | -73.863060 | 40.769581 | 5 | 6 |
L6.070283.13.02.02.06.34.29 | -73.945541 | 40.779423 | 1 | 6 |
EASE-DGGS to geo boundary¶
In [3]:
Copied!
df = df.ease.ease2geo()
df.head()
df = df.ease.ease2geo()
df.head()
Out[3]:
lon | lat | passenger_count | ease_res | geometry | |
---|---|---|---|---|---|
ease | |||||
L6.070283.13.01.20.89.78.88 | -73.993896 | 40.750111 | 1 | 6 | POLYGON ((-73.9939 40.7501, -73.99389 40.7501,... |
L6.070283.13.11.02.86.77.82 | -73.976425 | 40.739811 | 1 | 6 | POLYGON ((-73.97643 40.7398, -73.97642 40.7398... |
L6.070283.13.02.20.44.71.66 | -73.968704 | 40.754246 | 5 | 6 | POLYGON ((-73.96871 40.75424, -73.9687 40.7542... |
L6.070284.10.02.01.96.80.71 | -73.863060 | 40.769581 | 5 | 6 | POLYGON ((-73.86306 40.76958, -73.86305 40.769... |
L6.070283.13.02.02.06.34.29 | -73.945541 | 40.779423 | 1 | 6 | POLYGON ((-73.94555 40.77941, -73.94554 40.779... |
(Multi)Linestring/ (Multi)Polygon to EASE-DGGS¶
In [4]:
Copied!
from vgridpandas import easepandas
import geopandas as gpd
gdf = gpd.read_file('https://raw.githubusercontent.com/opengeoshub/vopendata/refs/heads/main/shape/polygon.geojson')
resolution = 4
gdf_polyfill = gdf.ease.polyfill(resolution, compact = False, predicate = "intersects", explode = False)
gdf_polyfill = gdf_polyfill.ease.ease2geo(ease_column = "ease")
gdf_polyfill.plot(edgecolor = "white")
from vgridpandas import easepandas
import geopandas as gpd
gdf = gpd.read_file('https://raw.githubusercontent.com/opengeoshub/vopendata/refs/heads/main/shape/polygon.geojson')
resolution = 4
gdf_polyfill = gdf.ease.polyfill(resolution, compact = False, predicate = "intersects", explode = False)
gdf_polyfill = gdf_polyfill.ease.ease2geo(ease_column = "ease")
gdf_polyfill.plot(edgecolor = "white")
Out[4]:
<Axes: >
EASE-DGGS point binning¶
In [5]:
Copied!
import pandas as pd
from vgridpandas import easepandas
resolution = 4
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.ease.easebin(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
from vgridpandas import easepandas
resolution = 4
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.ease.easebin(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: >