Skip to content

Commit 4db3249

Browse files
committed
make data examples available in folium
1 parent 8cf9690 commit 4db3249

10 files changed

Lines changed: 291 additions & 0 deletions

folium/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
MacroElement,
1313
)
1414

15+
from folium import example_data
1516
from folium.features import (
1617
Choropleth,
1718
ClickForLatLng,
@@ -101,4 +102,5 @@
101102
"PolyLine",
102103
"Polygon",
103104
"Rectangle",
105+
"example_data",
104106
]

folium/example_data.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import ast
2+
import json
3+
import os
4+
5+
6+
def get_path(filename):
7+
package_path = os.path.dirname(os.path.abspath(__file__))
8+
return os.path.join(package_path, "example_data", filename)
9+
10+
11+
def us_states_geojson():
12+
with open(get_path("us_states.json")) as f:
13+
return json.load(f)
14+
15+
16+
def world_countries_geojson():
17+
with open(get_path("world_countries.json")) as f:
18+
return json.load(f)
19+
20+
21+
def antarctic_ice_shelf_topojson():
22+
with open(get_path("antarctic_ice_shelf_topo.json")) as f:
23+
return json.load(f)
24+
25+
26+
def new_york_boroughs_geodataframe():
27+
import geopandas
28+
29+
return geopandas.read_file(get_path("new_york_boroughs.zip"))
30+
31+
32+
def subway_stations_geodataframe():
33+
import geopandas
34+
35+
return geopandas.read_file(get_path("subway_stations.geojson"))
36+
37+
38+
def us_unemployment_pandas_dataframe():
39+
import pandas
40+
41+
return pandas.read_csv(get_path("us_unemployment_oct_2012.csv"))
42+
43+
44+
def us_labor_force_pandas_dataframe():
45+
import pandas
46+
47+
return pandas.read_csv(get_path("us_labor_force_2011.csv"))
48+
49+
50+
def language_coordinates_and_stats_pandas_dataframe():
51+
import pandas
52+
53+
return pandas.read_csv(
54+
get_path("consonants_vowels.csv"),
55+
# To ensure that tuples are read as tuples
56+
converters={"coordinates": ast.literal_eval},
57+
)

folium/example_data/antarctic_ice_shelf_topo.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
648 KB
Binary file not shown.
File renamed without changes.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
State,Civilian_labor_force_2011
2+
AK,734088
3+
AL,4381044
4+
AR,2739713
5+
AZ,6068526
6+
CA,36769777
7+
CO,5446060
8+
CT,3836253
9+
DC,688666
10+
DE,878362
11+
FL,18497016
12+
GA,9450224
13+
HI,1321389
14+
IA,3327192
15+
ID,1541284
16+
IL,13131016
17+
IN,6376531
18+
KS,3010089
19+
KY,4135063
20+
LA,4121280
21+
MA,6912888
22+
MD,6144496
23+
ME,1408165
24+
MI,9316223
25+
MN,5955846
26+
MO,6092613
27+
MS,2687701
28+
MT,1008827
29+
NC,9307828
30+
ND,765893
31+
NE,2010916
32+
NH,1476565
33+
NJ,9112377
34+
NM,1855573
35+
NV,2771746
36+
NY,19008485
37+
OH,11612938
38+
OK,3541653
39+
OR,3983748
40+
PA,12771420
41+
RI,1126827
42+
SC,4314536
43+
SD,892509
44+
TN,6265493
45+
TX,24903029
46+
UT,2676522
47+
VA,8612348
48+
VT,718331
49+
WA,6969630
50+
WI,6124525
51+
WV,1599769
52+
WY,608485
File renamed without changes.
File renamed without changes.

folium/example_data/world_countries.json

Lines changed: 179 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)