Skip to content

Commit d52d4a5

Browse files
committed
black
1 parent 7271c9a commit d52d4a5

File tree

1 file changed

+110
-50
lines changed

1 file changed

+110
-50
lines changed

guide/12-enrich-data-with-thematic-information/part2_where_to_enrich_study_areas.ipynb

Lines changed: 110 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"outputs": [],
6868
"source": [
6969
"# Create a GIS Connection\n",
70-
"gis = GIS(profile='your_online_profile')"
70+
"gis = GIS(profile=\"your_online_profile\")"
7171
]
7272
},
7373
{
@@ -88,7 +88,7 @@
8888
],
8989
"source": [
9090
"# Get US as a country\n",
91-
"usa = Country.get('US')\n",
91+
"usa = Country.get(\"US\")\n",
9292
"type(usa)"
9393
]
9494
},
@@ -309,7 +309,7 @@
309309
}
310310
],
311311
"source": [
312-
"df.loc['Age']['analysisVariable'].unique()"
312+
"df.loc[\"Age\"][\"analysisVariable\"].unique()"
313313
]
314314
},
315315
{
@@ -416,7 +416,7 @@
416416
],
417417
"source": [
418418
"# View a sample of the `Age` data collection\n",
419-
"df.loc['Age'].head()"
419+
"df.loc[\"Age\"].head()"
420420
]
421421
},
422422
{
@@ -458,8 +458,9 @@
458458
"outputs": [],
459459
"source": [
460460
"# Enriching single address as single line imput\n",
461-
"single_address = enrich(study_areas=[\"380 New York St Redlands CA 92373\"], \n",
462-
" data_collections=['Age'])"
461+
"single_address = enrich(\n",
462+
" study_areas=[\"380 New York St Redlands CA 92373\"], data_collections=[\"Age\"]\n",
463+
")"
463464
]
464465
},
465466
{
@@ -595,7 +596,7 @@
595596
"outputs": [],
596597
"source": [
597598
"# Plot on a map\n",
598-
"address_map = gis.map('Redlands, CA')\n",
599+
"address_map = gis.map(\"Redlands, CA\")\n",
599600
"address_map"
600601
]
601602
},
@@ -775,9 +776,23 @@
775776
],
776777
"source": [
777778
"# Enriching multiple addresses as single line input\n",
778-
"enrich(study_areas=[{\"address\":{\"text\":\"12 Concorde Place Toronto ON M3C 3R8\",\"sourceCountry\":\"Canada\"}},\n",
779-
" {\"address\":{\"text\":\"380 New York St Redlands CA 92373\",\"sourceCountry\":\"USA\"}}], \n",
780-
" data_collections=['Age'])"
779+
"enrich(\n",
780+
" study_areas=[\n",
781+
" {\n",
782+
" \"address\": {\n",
783+
" \"text\": \"12 Concorde Place Toronto ON M3C 3R8\",\n",
784+
" \"sourceCountry\": \"Canada\",\n",
785+
" }\n",
786+
" },\n",
787+
" {\n",
788+
" \"address\": {\n",
789+
" \"text\": \"380 New York St Redlands CA 92373\",\n",
790+
" \"sourceCountry\": \"USA\",\n",
791+
" }\n",
792+
" },\n",
793+
" ],\n",
794+
" data_collections=[\"Age\"],\n",
795+
")"
781796
]
782797
},
783798
{
@@ -894,9 +909,19 @@
894909
}
895910
],
896911
"source": [
897-
"enrich(study_areas=[{\"address\":{\"Address\":\"380 New York Street\", \n",
898-
" \"City\":\"Redlands\", \"Region\":\"CA\", \"Postal\":92373}}], \n",
899-
" data_collections=['Age'])"
912+
"enrich(\n",
913+
" study_areas=[\n",
914+
" {\n",
915+
" \"address\": {\n",
916+
" \"Address\": \"380 New York Street\",\n",
917+
" \"City\": \"Redlands\",\n",
918+
" \"Region\": \"CA\",\n",
919+
" \"Postal\": 92373,\n",
920+
" }\n",
921+
" }\n",
922+
" ],\n",
923+
" data_collections=[\"Age\"],\n",
924+
")"
900925
]
901926
},
902927
{
@@ -995,8 +1020,10 @@
9951020
}
9961021
],
9971022
"source": [
998-
"enrich(study_areas=[\"380 New York St Redlands CA 92373\"], \n",
999-
" analysis_variables=[\"Age.FEM45\",\"Age.FEM55\",\"Age.FEM65\"])"
1023+
"enrich(\n",
1024+
" study_areas=[\"380 New York St Redlands CA 92373\"],\n",
1025+
" analysis_variables=[\"Age.FEM45\", \"Age.FEM55\", \"Age.FEM65\"],\n",
1026+
")"
10001027
]
10011028
},
10021029
{
@@ -1128,8 +1155,8 @@
11281155
}
11291156
],
11301157
"source": [
1131-
"pt = Point({\"x\" : -117.1956, \"y\" : 34.0572, \"spatialReference\" : {\"wkid\" : 4326}})\n",
1132-
"enrich(study_areas=[pt], data_collections=['Age'])"
1158+
"pt = Point({\"x\": -117.1956, \"y\": 34.0572, \"spatialReference\": {\"wkid\": 4326}})\n",
1159+
"enrich(study_areas=[pt], data_collections=[\"Age\"])"
11331160
]
11341161
},
11351162
{
@@ -1272,10 +1299,10 @@
12721299
}
12731300
],
12741301
"source": [
1275-
"pt1 = Point({\"x\" : -122.435, \"y\" : 37.785, \"spatialReference\" : {\"wkid\" : 4326}})\n",
1276-
"pt2 = Point({\"x\" : -122.433, \"y\" : 37.734, \"spatialReference\" : {\"wkid\" : 4326}})\n",
1302+
"pt1 = Point({\"x\": -122.435, \"y\": 37.785, \"spatialReference\": {\"wkid\": 4326}})\n",
1303+
"pt2 = Point({\"x\": -122.433, \"y\": 37.734, \"spatialReference\": {\"wkid\": 4326}})\n",
12771304
"\n",
1278-
"enrich(study_areas=[pt1, pt2], data_collections=['Age'])"
1305+
"enrich(study_areas=[pt1, pt2], data_collections=[\"Age\"])"
12791306
]
12801307
},
12811308
{
@@ -1300,9 +1327,13 @@
13001327
"metadata": {},
13011328
"outputs": [],
13021329
"source": [
1303-
"line = Polyline({\"paths\":[[[-13048580,4036370],[-13046151,4036366]]],\n",
1304-
" \"spatialReference\":{\"wkid\":102100}})\n",
1305-
"enriched_line_df = enrich(study_areas=[line], data_collections=['Age'])"
1330+
"line = Polyline(\n",
1331+
" {\n",
1332+
" \"paths\": [[[-13048580, 4036370], [-13046151, 4036366]]],\n",
1333+
" \"spatialReference\": {\"wkid\": 102100},\n",
1334+
" }\n",
1335+
")\n",
1336+
"enriched_line_df = enrich(study_areas=[line], data_collections=[\"Age\"])"
13061337
]
13071338
},
13081339
{
@@ -1428,7 +1459,7 @@
14281459
"outputs": [],
14291460
"source": [
14301461
"# Plot on a map\n",
1431-
"line_map = gis.map('Redlands, CA')\n",
1462+
"line_map = gis.map(\"Redlands, CA\")\n",
14321463
"line_map"
14331464
]
14341465
},
@@ -1590,11 +1621,21 @@
15901621
}
15911622
],
15921623
"source": [
1593-
"poly = Polygon({\"rings\":[[[-117.185412,34.063170],[-122.81,37.81],\n",
1594-
" [-117.200570,34.057196],[-117.185412,34.063170]]],\n",
1595-
" \"spatialReference\":{\"wkid\":4326}})\n",
1624+
"poly = Polygon(\n",
1625+
" {\n",
1626+
" \"rings\": [\n",
1627+
" [\n",
1628+
" [-117.185412, 34.063170],\n",
1629+
" [-122.81, 37.81],\n",
1630+
" [-117.200570, 34.057196],\n",
1631+
" [-117.185412, 34.063170],\n",
1632+
" ]\n",
1633+
" ],\n",
1634+
" \"spatialReference\": {\"wkid\": 4326},\n",
1635+
" }\n",
1636+
")\n",
15961637
"\n",
1597-
"enrich(study_areas=[poly], data_collections=['Age'])"
1638+
"enrich(study_areas=[poly], data_collections=[\"Age\"])"
15981639
]
15991640
},
16001641
{
@@ -1637,9 +1678,13 @@
16371678
},
16381679
"outputs": [],
16391680
"source": [
1640-
"buffered = BufferStudyArea(area='380 New York St Redlands CA 92373',\n",
1641-
" radii=[1,3,5], units='Miles', overlap=False)\n",
1642-
"drive_dist_df = enrich(study_areas=[buffered], data_collections=['Age'])"
1681+
"buffered = BufferStudyArea(\n",
1682+
" area=\"380 New York St Redlands CA 92373\",\n",
1683+
" radii=[1, 3, 5],\n",
1684+
" units=\"Miles\",\n",
1685+
" overlap=False,\n",
1686+
")\n",
1687+
"drive_dist_df = enrich(study_areas=[buffered], data_collections=[\"Age\"])"
16431688
]
16441689
},
16451690
{
@@ -1828,8 +1873,8 @@
18281873
"outputs": [],
18291874
"source": [
18301875
"# Plot on a map\n",
1831-
"buffer_map1 = gis.map('Redlands, CA')\n",
1832-
"buffer_map1.basemap.basemap = 'dark-gray-vector'\n",
1876+
"buffer_map1 = gis.map(\"Redlands, CA\")\n",
1877+
"buffer_map1.basemap.basemap = \"dark-gray-vector\"\n",
18331878
"buffer_map1"
18341879
]
18351880
},
@@ -1868,7 +1913,12 @@
18681913
"source": [
18691914
"renderer_manager = buffer_map1.content.renderer(0)\n",
18701915
"smart_mapping_manager = renderer_manager.smart_mapping()\n",
1871-
"smart_mapping_manager.class_breaks_renderer(break_type=\"size\", classification_method=\"esriClassifyNaturalBreaks\", num_classes=4, field=\"buffer_radii\")"
1916+
"smart_mapping_manager.class_breaks_renderer(\n",
1917+
" break_type=\"size\",\n",
1918+
" classification_method=\"esriClassifyNaturalBreaks\",\n",
1919+
" num_classes=4,\n",
1920+
" field=\"buffer_radii\",\n",
1921+
")"
18721922
]
18731923
},
18741924
{
@@ -1894,10 +1944,13 @@
18941944
},
18951945
"outputs": [],
18961946
"source": [
1897-
"buffered = BufferStudyArea(area='380 New York St Redlands CA 92373', \n",
1898-
" radii=[5, 10], units='Minutes', \n",
1899-
" travel_mode='Driving')\n",
1900-
"drive_time_df = enrich(study_areas=[buffered], data_collections=['Age'])"
1947+
"buffered = BufferStudyArea(\n",
1948+
" area=\"380 New York St Redlands CA 92373\",\n",
1949+
" radii=[5, 10],\n",
1950+
" units=\"Minutes\",\n",
1951+
" travel_mode=\"Driving\",\n",
1952+
")\n",
1953+
"drive_time_df = enrich(study_areas=[buffered], data_collections=[\"Age\"])"
19011954
]
19021955
},
19031956
{
@@ -2064,8 +2117,8 @@
20642117
"outputs": [],
20652118
"source": [
20662119
"# Plot on a map\n",
2067-
"buffer_map2 = gis.map('Redlands, CA')\n",
2068-
"buffer_map2.basemap.basemap = 'gray-vector'\n",
2120+
"buffer_map2 = gis.map(\"Redlands, CA\")\n",
2121+
"buffer_map2.basemap.basemap = \"gray-vector\"\n",
20692122
"buffer_map2"
20702123
]
20712124
},
@@ -2104,7 +2157,12 @@
21042157
"source": [
21052158
"renderer_manager = buffer_map1.content.renderer(0)\n",
21062159
"smart_mapping_manager = renderer_manager.smart_mapping()\n",
2107-
"smart_mapping_manager.class_breaks_renderer(break_type=\"size\", classification_method=\"esriClassifyNaturalBreaks\", num_classes=3, field=\"buffer_radii\")"
2160+
"smart_mapping_manager.class_breaks_renderer(\n",
2161+
" break_type=\"size\",\n",
2162+
" classification_method=\"esriClassifyNaturalBreaks\",\n",
2163+
" num_classes=3,\n",
2164+
" field=\"buffer_radii\",\n",
2165+
")"
21082166
]
21092167
},
21102168
{
@@ -2134,7 +2192,7 @@
21342192
"metadata": {},
21352193
"outputs": [],
21362194
"source": [
2137-
"usa = Country.get('US')"
2195+
"usa = Country.get(\"US\")"
21382196
]
21392197
},
21402198
{
@@ -2147,7 +2205,7 @@
21472205
},
21482206
"outputs": [],
21492207
"source": [
2150-
"redlands = usa.subgeographies.states['California'].zip5['92373']"
2208+
"redlands = usa.subgeographies.states[\"California\"].zip5[\"92373\"]"
21512209
]
21522210
},
21532211
{
@@ -2200,7 +2258,7 @@
22002258
},
22012259
"outputs": [],
22022260
"source": [
2203-
"redlands_df = enrich(study_areas=[redlands], data_collections=['Age'] )"
2261+
"redlands_df = enrich(study_areas=[redlands], data_collections=[\"Age\"])"
22042262
]
22052263
},
22062264
{
@@ -2326,7 +2384,7 @@
23262384
"metadata": {},
23272385
"outputs": [],
23282386
"source": [
2329-
"zip_map = gis.map('Redlands, CA')\n",
2387+
"zip_map = gis.map(\"Redlands, CA\")\n",
23302388
"zip_map"
23312389
]
23322390
},
@@ -2386,7 +2444,7 @@
23862444
},
23872445
"outputs": [],
23882446
"source": [
2389-
"ca_counties = usa.subgeographies.states['California'].counties"
2447+
"ca_counties = usa.subgeographies.states[\"California\"].counties"
23902448
]
23912449
},
23922450
{
@@ -2613,7 +2671,7 @@
26132671
}
26142672
],
26152673
"source": [
2616-
"counties_df = enrich(study_areas=ca_counties, data_collections=['Age'])\n",
2674+
"counties_df = enrich(study_areas=ca_counties, data_collections=[\"Age\"])\n",
26172675
"counties_df.head()"
26182676
]
26192677
},
@@ -2844,7 +2902,9 @@
28442902
}
28452903
],
28462904
"source": [
2847-
"counties_df2 = usa.enrich(study_areas=list(ca_counties.values()), data_collections=['transportation'])\n",
2905+
"counties_df2 = usa.enrich(\n",
2906+
" study_areas=list(ca_counties.values()), data_collections=[\"transportation\"]\n",
2907+
")\n",
28482908
"counties_df2.head()"
28492909
]
28502910
},
@@ -2861,7 +2921,7 @@
28612921
"metadata": {},
28622922
"outputs": [],
28632923
"source": [
2864-
"county_map = gis.map('California')\n",
2924+
"county_map = gis.map(\"California\")\n",
28652925
"county_map"
28662926
]
28672927
},
@@ -2898,7 +2958,7 @@
28982958
"metadata": {},
28992959
"outputs": [],
29002960
"source": [
2901-
"county_map.legend.enabled=True"
2961+
"county_map.legend.enabled = True"
29022962
]
29032963
},
29042964
{

0 commit comments

Comments
 (0)