05 isea4t
ISEA4TPandas 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
OpenEAGGR ISEA4T¶
Latlong to OpenEAGGR ISEA4T¶
In [9]:
Copied!
import pandas as pd
from vgridpandas import isea4tpandas
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.isea4t.latlon2isea4t(resolution)
df.head()
import pandas as pd
from vgridpandas import isea4tpandas
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.isea4t.latlon2isea4t(resolution)
df.head()
Out[9]:
lon | lat | passenger_count | isea4t_res | |
---|---|---|---|---|
isea4t | ||||
010102302222012122 | -73.993896 | 40.750111 | 1 | 16 |
010102302222031012 | -73.976425 | 40.739811 | 1 | 16 |
010102302222301201 | -73.968704 | 40.754246 | 5 | 16 |
010102312201111201 | -73.863060 | 40.769581 | 5 | 16 |
010102312220100100 | -73.945541 | 40.779423 | 1 | 16 |
OpenEAGGR ISEA4T to geo boundary¶
In [10]:
Copied!
df = df.isea4t.isea4t2geo()
df.head()
df = df.isea4t.isea4t2geo()
df.head()
Out[10]:
lon | lat | passenger_count | isea4t_res | geometry | |
---|---|---|---|---|---|
isea4t | |||||
010102302222012122 | -73.993896 | 40.750111 | 1 | 16 | POLYGON ((-73.99399 40.75029, -73.99462 40.749... |
010102302222031012 | -73.976425 | 40.739811 | 1 | 16 | POLYGON ((-73.97647 40.73898, -73.97716 40.739... |
010102302222301201 | -73.968704 | 40.754246 | 5 | 16 | POLYGON ((-73.96834 40.75345, -73.96903 40.754... |
010102312201111201 | -73.863060 | 40.769581 | 5 | 16 | POLYGON ((-73.86317 40.7699, -73.8638 40.76893... |
010102312220100100 | -73.945541 | 40.779423 | 1 | 16 | POLYGON ((-73.94534 40.77862, -73.94603 40.779... |
(Multi)Linestring/ (Multi)Polygon to ISEA4T¶
In [4]:
Copied!
from vgridpandas import isea4tpandas
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.isea4t.polyfill(resolution, compact = True, predicate = "intersects", explode = False)
gdf_polyfill = gdf_polyfill.isea4t.isea4t2geo(isea4t_column = "isea4t")
gdf_polyfill.plot(edgecolor = "white")
from vgridpandas import isea4tpandas
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.isea4t.polyfill(resolution, compact = True, predicate = "intersects", explode = False)
gdf_polyfill = gdf_polyfill.isea4t.isea4t2geo(isea4t_column = "isea4t")
gdf_polyfill.plot(edgecolor = "white")
Out[4]:
<Axes: >
ISEA4T point binning¶
In [8]:
Copied!
import pandas as pd
import geopandas as gpd
from vgridpandas import isea4tpandas
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.isea4t.isea4tbin(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 isea4tpandas
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.isea4t.isea4tbin(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[8]:
<Axes: >