PathLayer (lines)
In this notebook we will demonstrate using spatial polars to visualize spatial data on a Lonboard map using a path layer to visualize the polylines.
Note
This example makes use the geodatasets python package to access some spatial data easily.
Calling geodatasets.get_path() will download data the specified data to the machine and return the path to the downloaded file. If the file has already been downloaded it will simply return the path to the file.
See downloading and caching for further details.
Creating a PathLayer
The following cell will read the eea large rivers polyline dataset into a dataframe and create a Lonboard PathLayer
Creating a pathlayer
import geodatasets
from lonboard import Map
from spatial_polars import read_spatial
large_rivers_df = read_spatial(geodatasets.get_path("eea.large_rivers")) # (1)!
pathlayer = large_rivers_df.spatial.to_pathlayer( # (2)!
auto_highlight=True, # (3)!
color=(0, 0, 255), # (4)!
width_min_pixels=5, # (5)!
)
pathlayer_map = Map(layers=[pathlayer]) # (6)!
pathlayer_map
- Read the eea.large_rivers geodataset into a dataframe
- Create a pathlayer from the dataframe
- When we mouse over a point in the map, it will change color
- Color all the lines blue
- Make them always at least 5px wide on the
- Add layer to a map and display it