Skip to content

84 read parquet

image image image

Reading GeoParquet files and visualizing vector data interactively

Uncomment the following line to install leafmap if needed.

1
# %pip install -U leafmap lonboard
1
import leafmap

Visualizing point data.

1
url = "https://github.com/opengeos/data/raw/refs/heads/main/duckdb/cities.parquet"

Read GeoParquet and return a GeoPandas GeoDataFrame.

1
2
gdf = leafmap.read_parquet(url, return_type="gdf", src_crs="EPSG:4326")
gdf.head()

View the GeoDataFrame interactively using folium.

1
gdf.explore()

Visualize the GeoDataFrame using lonboard.

1
leafmap.view_vector(gdf, get_radius=20000, get_fill_color="blue")

Visualizing polygon data.

1
url = "https://data.source.coop/giswqs/nwi/wetlands/DC_Wetlands.parquet"
1
2
3
4
gdf = leafmap.read_parquet(
    url, return_type="gdf", src_crs="EPSG:5070", dst_crs="EPSG:4326"
)
gdf.head()
1
gdf.explore()
1
leafmap.view_vector(gdf, get_fill_color=[0, 0, 255, 128])

vector

Alternatively, you can specify a color map to visualize the data.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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),
}
1
leafmap.view_vector(gdf, color_column="WETLAND_TYPE", color_map=color_map, opacity=0.5)

vector-color

Display a legend for the data.

1
leafmap.Legend(title="Wetland Type", legend_dict=color_map)

legend