Geoprocessing#
[6]:
import footbridge as ft
import geopandas as gpd
# large dataset of US National Highway System roads
# https://hepgis-usdot.hub.arcgis.com/datasets/dce9f09392eb474c8ad8e6a78416279b_0
fc1 = ft.FeatureClass("NHS.gdb/National_Highway_System__NHS_")
f"{len(fc1)} rows"
[6]:
'492005 rows'
[12]:
# filter by route ID
route = " I 017"
field_name = "ROUTEID"
column_index = fc1.list_fields().index(field_name)
filtered = list()
for row in fc1:
if row[column_index] == route:
filtered.append(row)
fc2 = ft.FeatureClass(gpd.GeoDataFrame(filtered))
f"{len(fc2)} rows where ROUTEID == '{route}'"
[12]:
"100 rows where ROUTEID == ' I 017'"
[18]:
# TODO buffer with GeoPandas
gdf_buf = ft.buffer(fc2, 10000)
gdf_buf.show()
[19]:
# Load results into a new feature class and geodatabase in memory
fc3 = ft.FeatureClass(gdf_buf)
gdb = ft.GeoDatabase()
gdb["NHS_selection_buffered"] = fc3
[20]:
# Save to disk
gdb.save("NHS_selection.gdb", overwrite=True)
ft.list_datasets("NHS_selection.gdb")
[20]:
{None: ['NHS_selection_buffered']}