84 read parquet
Reading GeoParquet files and visualizing vector data interactively
Uncomment the following line to install leafmap if needed.
In [ ]:
Copied!
# %pip install -U leafmap lonboard==0.3.0
# %pip install -U leafmap lonboard==0.3.0
In [ ]:
Copied!
import leafmap
import leafmap
Visualizing point data.
In [ ]:
Copied!
url = "https://open.gishub.org/data/duckdb/cities.parquet"
url = "https://open.gishub.org/data/duckdb/cities.parquet"
Read GeoParquet and return a GeoPandas GeoDataFrame.
In [ ]:
Copied!
gdf = leafmap.read_parquet(url, return_type="gdf", src_crs="EPSG:4326")
gdf.head()
gdf = leafmap.read_parquet(url, return_type="gdf", src_crs="EPSG:4326")
gdf.head()
View the GeoDataFrame interactively using folium.
In [ ]:
Copied!
gdf.explore()
gdf.explore()
Visualize the GeoDataFrame using lonboard.
In [ ]:
Copied!
leafmap.view_vector(gdf, get_radius=20000, get_fill_color="blue")
leafmap.view_vector(gdf, get_radius=20000, get_fill_color="blue")
Visualizing polygon data.
In [ ]:
Copied!
url = "https://data.source.coop/giswqs/nwi/wetlands/DC_Wetlands.parquet"
url = "https://data.source.coop/giswqs/nwi/wetlands/DC_Wetlands.parquet"
In [ ]:
Copied!
gdf = leafmap.read_parquet(
url, return_type="gdf", src_crs="EPSG:5070", dst_crs="EPSG:4326"
)
gdf.head()
gdf = leafmap.read_parquet(
url, return_type="gdf", src_crs="EPSG:5070", dst_crs="EPSG:4326"
)
gdf.head()
In [ ]:
Copied!
gdf.explore()
gdf.explore()
In [ ]:
Copied!
leafmap.view_vector(gdf, get_fill_color=[0, 0, 255, 128])
leafmap.view_vector(gdf, get_fill_color=[0, 0, 255, 128])
Alternatively, you can specify a color map to visualize the data.
In [ ]:
Copied!
color_map = {
"Freshwater Forested/Shrub Wetland": (0, 136, 55),
"Freshwater Emergent Wetland": (127, 195, 28),
"Freshwater Pond": (104, 140, 192),
"Estuarine and Marine Wetland": (102, 194, 165),
"Riverine": (1, 144, 191),
"Lake": (19, 0, 124),
"Estuarine and Marine Deepwater": (0, 124, 136),
"Other": (178, 134, 86),
}
color_map = {
"Freshwater Forested/Shrub Wetland": (0, 136, 55),
"Freshwater Emergent Wetland": (127, 195, 28),
"Freshwater Pond": (104, 140, 192),
"Estuarine and Marine Wetland": (102, 194, 165),
"Riverine": (1, 144, 191),
"Lake": (19, 0, 124),
"Estuarine and Marine Deepwater": (0, 124, 136),
"Other": (178, 134, 86),
}
In [ ]:
Copied!
leafmap.view_vector(gdf, color_column="WETLAND_TYPE", color_map=color_map, opacity=0.5)
leafmap.view_vector(gdf, color_column="WETLAND_TYPE", color_map=color_map, opacity=0.5)
Display a legend for the data.
In [ ]:
Copied!
leafmap.Legend(title="Wetland Type", legend_dict=color_map)
leafmap.Legend(title="Wetland Type", legend_dict=color_map)