#!/usr/bin/env python # coding: utf-8 # [![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/84_read_parquet.ipynb) # [![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/notebooks/84_read_parquet.ipynb) # [![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD) # # **Reading GeoParquet files and visualizing vector data interactively** # # Uncomment the following line to install [leafmap](https://leafmap.org) if needed. # In[ ]: # %pip install -U leafmap lonboard # In[ ]: import leafmap # Visualizing point data. # In[ ]: url = "https://github.com/opengeos/data/raw/refs/heads/main/duckdb/cities.parquet" # Read GeoParquet and return a GeoPandas GeoDataFrame. # In[ ]: gdf = leafmap.read_parquet(url, return_type="gdf", src_crs="EPSG:4326") gdf.head() # View the GeoDataFrame interactively using folium. # In[ ]: gdf.explore() # Visualize the GeoDataFrame using lonboard. # In[ ]: leafmap.view_vector(gdf, get_radius=20000, get_fill_color="blue") # Visualizing polygon data. # In[ ]: url = "https://data.source.coop/giswqs/nwi/wetlands/DC_Wetlands.parquet" # In[ ]: gdf = leafmap.read_parquet( url, return_type="gdf", src_crs="EPSG:5070", dst_crs="EPSG:4326" ) gdf.head() # In[ ]: gdf.explore() # In[ ]: leafmap.view_vector(gdf, get_fill_color=[0, 0, 255, 128]) # ![vector](https://i.imgur.com/HRtpiVd.png) # Alternatively, you can specify a color map to visualize the data. # In[ ]: 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[ ]: leafmap.view_vector(gdf, color_column="WETLAND_TYPE", color_map=color_map, opacity=0.5) # ![vector-color](https://i.imgur.com/Ejh8hK6.png) # Display a legend for the data. # In[ ]: leafmap.Legend(title="Wetland Type", legend_dict=color_map) # ![legend](https://i.imgur.com/fxzHHFN.png)