Skip to content

Vis

In this notebook we will demonstrate using spatial polars to visualize spatial data on a Lonboard map using Lonboard's .vis function.

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.

Sometimes you just want to see stuff on a map to check out what the data looks like, you dont really care about the colors or any specifics, just show me something. Lonboard's viz has you covered. All we have to do is call .spatial.viz() and it will take the data in our dataframe and add it to a map, no need to fiddle with making a map and a layer and adding the layer to the map, super easy! If you have specific parameters to set for the layer or map, they can be provided as dictionaries to the *_kwargs parameters for the layer type or the map.

In the example below we'll read the geoda.milwaukee1 dataset into a dataframe and the call .spatial.viz() from the dataframe, and it will give us a map showing some polygons around the Milwaukee area. Big shout out to all my people over in Mukwonago (it's where ya wanna go!)

using .viz
import geodatasets

from spatial_polars import read_spatial

geoda_milwaukee1_df = read_spatial(geodatasets.get_path("geoda.milwaukee1"))  # (1)!
milwaukee_map = geoda_milwaukee1_df.spatial.viz()  # (2)!

milwaukee_map
  1. Read the geoda.milwaukee1 geodataset into a dataframe
  2. Create a map from the dataframe using viz with no kwargs