opengeos/leafmap

extruding point data from geojson using leafmap.deck fails

cboettig opened this issue · 1 comments

Environment Information

  • leafmap version: 0.32.1
  • Python version: 3.10.12
  • Operating System: Linux (ubuntu 22.04)

Description

Trying to reproduce the pydeck code below using leafmap.deck, which uses 3d extrusion to represent numerical valued features from the geojson.

What I Did

in vanilla pydeck, I can do:

import geopandas as gpd
import pydeck as pdk

DATA_URL = 'https://data.source.coop/cboettig/conservation-policy/Inflation_Reduction_Act_Projects.geojson'
df = gpd.read_file(DATA_URL)

column_layer = pdk.Layer(
    "ColumnLayer",
    data=df,
    get_position=["LONGITUDE", "LATITUDE"],
    get_elevation="FUNDING_NUMERIC",
    get_fill_color = [256,256,0, 140],
    elevation_scale=.01,
    radius=10000,
    pickable=True,
    auto_highlight=True,
)

INITIAL_VIEW_STATE = pdk.ViewState(latitude=35, longitude=-100, zoom=4, max_zoom=16, pitch=45, bearing=0)

r = pdk.Deck(
    column_layer,
    initial_view_state = INITIAL_VIEW_STATE,
    map_style=pdk.map_styles.CARTO_ROAD,
)

r

I can't reproduce this in leafmap.deck though. with no arguments, leafmap will plot the point observations as flat data (presumably using the geometry rather than the lat and long columns as in the pydeck example). But I cannot get it to plot the extruded points based on funding value like in the pydeck example. Here's one combination I have tried:

import leafmap.deck as leafmap
import geopandas as gpd

m = leafmap.Map(center=(40, -100), zoom=3)
DATA_URL = 'https://data.source.coop/cboettig/conservation-policy/Inflation_Reduction_Act_Projects.geojson'
gdf = gpd.read_file(DATA_URL)

m.add_vector(gdf, get_position=["LONGITUDE", "LATITUDE"], get_elevation="FUNDING_NUMERIC",
    get_fill_color = [256,256,0, 140],
    elevation_scale=.01,
    radius=10000,
    pickable=True,
    auto_highlight=True,)
m

which give the error

Exception: 'GeoDataFrame' object has no attribute 'startswith'

Fixed in #758