Skip to content

Instantly share code, notes, and snippets.

@kylebarron
Created May 7, 2024 15:41
Show Gist options
  • Save kylebarron/59806c7f55d3ad88246b0e20a29ab4b6 to your computer and use it in GitHub Desktop.
Save kylebarron/59806c7f55d3ad88246b0e20a29ab4b6 to your computer and use it in GitHub Desktop.
# Old
m = leafmap.Map()
m.add_vector(broad_station_gdf, get_fill_color="blue")
m.add_vector(sts_near_broad_gdf, get_color="red", opacity=0.5)
m.add_vector(streets_gdf, get_color="grey", zoom_to_layer=False, opacity=0.3)
m
# New: simple method, just want to see my data:
from lonboard import viz
viz(
[
broad_station_gdf,
sts_near_broad_gdf,
streets_gdf,
]
)
# New: detailed method with specific rendering options
from lonboard import Map, ScatterplotLayer, PathLayer
# broad_station_gdf: Point geometries
# sts_near_broad_gdf: (Multi)LineString geometries
# streets_gdf: (Multi)LineString geometries
broad_station_layer = ScatterplotLayer.from_geopandas(
broad_station_gdf, get_fill_color="blue"
)
sts_near_broad_layer = PathLayer.from_geopandas(
sts_near_broad_gdf, get_color="red", opacity=0.5
)
streets_layer = PathLayer.from_geopandas(streets_gdf, get_color="grey", opacity=0.3)
m = Map(
[
broad_station_layer,
sts_near_broad_layer,
streets_layer,
]
)
m
# This also gives better context to why the parameter passed in to `broad_station_gdf`
# is named `get_fill_color` while the parameter for the other two is `get_color`. This
# is because they're rendered as separate deck.gl Layer types, and the point layer also
# has a `get_line_color` parameter for rendering the outline of the point.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment