In [1]:
Copied!
# %pip install "leafmap[maplibre]"
# %pip install "leafmap[maplibre]"
In [2]:
Copied!
import geopandas as gpd
import leafmap.maplibregl as leafmap
import geopandas as gpd
import leafmap.maplibregl as leafmap
In [3]:
Copied!
geojson = "https://github.com/opengeos/datasets/releases/download/us/zillow_home_value_by_county.geojson"
geojson = "https://github.com/opengeos/datasets/releases/download/us/zillow_home_value_by_county.geojson"
In [4]:
Copied!
gdf = gpd.read_file(geojson)
gdf.head()
gdf = gpd.read_file(geojson)
gdf.head()
Out[4]:
index | RegionID | SizeRank | RegionName | RegionType | StateName | State | Metro | StateCodeFIPS | MunicipalCodeFIPS | ... | 2024-02-29 | 2024-03-31 | 2024-04-30 | 2024-05-31 | 2024-06-30 | 2024-07-31 | 2024-08-31 | 2024-09-30 | 2024-10-31 | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | geoId/06037 | 3101 | 0 | Los Angeles County | county | CA | CA | Los Angeles-Long Beach-Anaheim, CA | 06 | 037 | ... | 851218.324044 | 847438.710237 | 848072.053695 | 851221.654671 | 853300.031599 | 856929.899269 | 862101.367502 | 868683.388483 | 873790.400103 | MULTIPOLYGON (((-118.67855 33.02634, -118.6748... |
1 | geoId/17031 | 139 | 1 | Cook County | county | IL | IL | Chicago-Naperville-Elgin, IL-IN-WI | 17 | 031 | ... | 297281.192639 | 299300.336191 | 301953.165715 | 303791.255067 | 304848.668699 | 305508.214099 | 306334.939254 | 307007.292144 | 307364.376614 | POLYGON ((-88.26308 42.06686, -88.26272 41.986... |
2 | geoId/48201 | 1090 | 2 | Harris County | county | TX | TX | Houston-The Woodlands-Sugar Land, TX | 48 | 201 | ... | 278094.301024 | 279085.366023 | 280116.831608 | 280701.913405 | 280585.041362 | 280219.238295 | 279883.927250 | 279671.324691 | 279308.720918 | POLYGON ((-95.96052 30.16368, -95.92658 30.068... |
3 | geoId/04013 | 2402 | 3 | Maricopa County | county | AZ | AZ | Phoenix-Mesa-Chandler, AZ | 04 | 013 | ... | 465567.119242 | 467017.617878 | 468789.154601 | 470188.977576 | 470357.292903 | 469753.783114 | 468639.799637 | 467695.338296 | 466966.903423 | POLYGON ((-113.33376 33.99923, -113.33389 32.5... |
4 | geoId/06073 | 2841 | 4 | San Diego County | county | CA | CA | San Diego-Chula Vista-Carlsbad, CA | 06 | 073 | ... | 903677.977515 | 911839.212243 | 922026.061494 | 930747.253219 | 935215.065410 | 936652.178767 | 936216.423469 | 935770.997631 | 935062.165130 | POLYGON ((-117.61109 33.33401, -117.57155 33.3... |
5 rows × 309 columns
In [5]:
Copied!
column = "2024-10-31"
data = gdf[["RegionName", "State", column, "geometry"]]
data.head()
column = "2024-10-31"
data = gdf[["RegionName", "State", column, "geometry"]]
data.head()
Out[5]:
RegionName | State | 2024-10-31 | geometry | |
---|---|---|---|---|
0 | Los Angeles County | CA | 873790.400103 | MULTIPOLYGON (((-118.67855 33.02634, -118.6748... |
1 | Cook County | IL | 307364.376614 | POLYGON ((-88.26308 42.06686, -88.26272 41.986... |
2 | Harris County | TX | 279308.720918 | POLYGON ((-95.96052 30.16368, -95.92658 30.068... |
3 | Maricopa County | AZ | 466966.903423 | POLYGON ((-113.33376 33.99923, -113.33389 32.5... |
4 | San Diego County | CA | 935062.165130 | POLYGON ((-117.61109 33.33401, -117.57155 33.3... |
Available classification schemes:
- BoxPlot
- EqualInterval
- FisherJenks
- FisherJenksSampled
- HeadTailBreaks
- JenksCaspall
- JenksCaspallForced
- JenksCaspallSampled
- MaxP
- MaximumBreaks
- NaturalBreaks
- Quantiles
- Percentiles
- StdMean
- UserDefined
In [6]:
Copied!
m = leafmap.Map(style="liberty", pitch=60)
first_symbol_id = m.find_first_symbol_layer()["id"]
m.add_data(
data,
column=column,
scheme="Quantiles",
cmap="Blues",
legend_title="Median Home Value",
name="Home value",
before_id=first_symbol_id,
extrude=True,
scale_factor=3,
)
m.add_layer_control()
m
m = leafmap.Map(style="liberty", pitch=60)
first_symbol_id = m.find_first_symbol_layer()["id"]
m.add_data(
data,
column=column,
scheme="Quantiles",
cmap="Blues",
legend_title="Median Home Value",
name="Home value",
before_id=first_symbol_id,
extrude=True,
scale_factor=3,
)
m.add_layer_control()
m
In [7]:
Copied!
m = leafmap.Map(style="liberty")
m.add_data(
data,
column=column,
scheme="Quantiles",
cmap="Blues",
legend_title="Median Home Value",
name="Home value",
before_id=first_symbol_id,
)
m.add_layer_control()
m
m = leafmap.Map(style="liberty")
m.add_data(
data,
column=column,
scheme="Quantiles",
cmap="Blues",
legend_title="Median Home Value",
name="Home value",
before_id=first_symbol_id,
)
m.add_layer_control()
m