Created
May 7, 2024 15:41
-
-
Save kylebarron/59806c7f55d3ad88246b0e20a29ab4b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
@kylebarron I'm trying to replace this in the existing blog https://ibis-project.org/posts/ibis-duckdb-geospatial/ and just use lonboard, without leafmap, but I noticed when I do the plots, I lose the automatic zoom I had with leafmap.
For example this plot,
renders
but when I convert this to
I loose the zoom, and I have to manually zoom, is there any way to automatically zoom to where the first two layers are?