Py.Cafe

giswqs/

vector-time-slider

Visualizing vector data with time attributes

DocsPricing
  • app.py
  • requirements.txt
  • zillow_home_value_index_by_county_ca.geojson
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import solara
import leafmap
import geopandas as gpd

class Map(leafmap.Map):

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        url = "zillow_home_value_index_by_county_ca.geojson"
        data = gpd.read_file(url)
        legend_dict = {
            "[ 0,  200000]": "#e6f3ff",       # Very light blue 
            "( 200000,  400000]": "#deebf7",  # Light blue
            "( 400000,  600000]": "#9ecae1",  # Medium blue
            "( 600000,  800000]": "#4292c6",  # Medium-dark blue
            "( 800000, 1000000]": "#2171b5",  # Dark blue
            "( 1000000, 2000000]": "#084594", # Very dark blue
            "Nodata": "#f0f0f0",              # Light gray  
        }
        gdf = leafmap.color_code_dataframe(data, legend_dict=legend_dict)
        self.add_gdf_time_slider(gdf, time_interval=0.05, zoom_to_layer=True, layer_name="Home Value")
        self.add_legend(title="Median Home Value", legend_dict=legend_dict)

@solara.component
def Page():
    solara.lab.theme.dark = False

    Map.element(
        height="750px"

    )