-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathjson_slice.py
85 lines (78 loc) · 2.68 KB
/
json_slice.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# %% [markdown]
# # Florida JSON
# %%
import json
from urllib.request import urlopen
with urlopen(
"https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json"
) as response:
counties = json.load(response)
# %% [markdown]
# | State | FIPS |
# |--------------------------|------|
# | Alabama | 01 |
# | Alaska | 02 |
# | Arizona | 04 |
# | Arkansas | 05 |
# | California | 06 |
# | Colorado | 08 |
# | Connecticut | 09 |
# | Delaware | 10 |
# | Florida | 12 |
# | Georgia | 13 |
# | Hawaii | 15 |
# | Idaho | 16 |
# | Illinois | 17 |
# | Indiana | 18 |
# | Iowa | 19 |
# | Kansas | 20 |
# | Kentucky | 21 |
# | Louisiana | 22 |
# | Maine | 23 |
# | Maryland | 24 |
# | Massachusetts | 25 |
# | Michigan | 26 |
# | Minnesota | 27 |
# | Mississippi | 28 |
# | Missouri | 29 |
# | Montana | 30 |
# | Nebraska | 31 |
# | Nevada | 32 |
# | New Hampshire | 33 |
# | New Jersey | 34 |
# | New Mexico | 35 |
# | New York | 36 |
# | North Carolina | 37 |
# | North Dakota | 38 |
# | Ohio | 39 |
# | Oklahoma | 40 |
# | Oregon | 41 |
# | Pennsylvania | 42 |
# | Rhode Island | 44 |
# | South Carolina | 45 |
# | South Dakota | 46 |
# | Tennessee | 47 |
# | Texas | 48 |
# | Utah | 49 |
# | Vermont | 50 |
# | Virginia | 51 |
# | Washington | 53 |
# | West Virginia | 54 |
# | Wisconsin | 55 |
# | Wyoming | 56 |
# | American Samoa | 60 |
# | Guam | 66 |
# | Northern Mariana Islands | 69 |
# | Puerto Rico | 72 |
# | Virgin Islands | 78 |
# %%
florida = []
# %%
for entry in counties.get("features"):
if entry.get("properties").get("STATE") == '12': ## Key feature to slice single state
florida.append(entry)
# %%
fl_json = dict(type="FeatureCollection", features=florida)
# %%
with open('fl_json.json', 'w') as fp:
json.dump(fl_json, fp)