|
48 | 48 | "metadata": {}, |
49 | 49 | "outputs": [], |
50 | 50 | "source": [ |
51 | | - "c1 = load_example('Charleston1')\n", |
52 | | - "c2 = load_example('Charleston2')" |
| 51 | + "c1 = load_example(\"Charleston1\")\n", |
| 52 | + "c2 = load_example(\"Charleston2\")" |
53 | 53 | ] |
54 | 54 | }, |
55 | 55 | { |
|
74 | 74 | "metadata": {}, |
75 | 75 | "outputs": [], |
76 | 76 | "source": [ |
77 | | - "tracts = gpd.read_file(c1.get_path('sc_final_census2.shp')).to_crs(crs)" |
| 77 | + "tracts = gpd.read_file(c1.get_path(\"sc_final_census2.shp\")).to_crs(crs)" |
78 | 78 | ] |
79 | 79 | }, |
80 | 80 | { |
|
83 | 83 | "metadata": {}, |
84 | 84 | "outputs": [], |
85 | 85 | "source": [ |
86 | | - "zip_codes = gpd.read_file(c2.get_path('CharlestonMSA2.shp')).to_crs(crs)" |
| 86 | + "zip_codes = gpd.read_file(c2.get_path(\"CharlestonMSA2.shp\")).to_crs(crs)" |
87 | 87 | ] |
88 | 88 | }, |
89 | 89 | { |
|
105 | 105 | } |
106 | 106 | ], |
107 | 107 | "source": [ |
108 | | - "fig, ax = plt.subplots(1,2, figsize=(14,7))\n", |
| 108 | + "fig, ax = plt.subplots(1, 2, figsize=(14, 7))\n", |
109 | 109 | "\n", |
110 | 110 | "tracts.plot(ax=ax[0])\n", |
111 | 111 | "zip_codes.plot(ax=ax[1])\n", |
112 | 112 | "\n", |
113 | 113 | "for ax in ax:\n", |
114 | | - " ax.axis('off')" |
| 114 | + " ax.axis(\"off\")" |
115 | 115 | ] |
116 | 116 | }, |
117 | 117 | { |
|
145 | 145 | "metadata": {}, |
146 | 146 | "outputs": [], |
147 | 147 | "source": [ |
148 | | - "tracts['pct_poverty'] = tracts.POV_POP/tracts.POV_TOT" |
| 148 | + "tracts[\"pct_poverty\"] = tracts.POV_POP / tracts.POV_TOT" |
149 | 149 | ] |
150 | 150 | }, |
151 | 151 | { |
|
168 | 168 | "metadata": {}, |
169 | 169 | "outputs": [], |
170 | 170 | "source": [ |
171 | | - "results = area_interpolate(source_df=tracts, target_df=zip_codes, intensive_variables=['pct_poverty'], extensive_variables=['EMP_MALE'])" |
| 171 | + "results = area_interpolate(\n", |
| 172 | + " source_df=tracts,\n", |
| 173 | + " target_df=zip_codes,\n", |
| 174 | + " intensive_variables=[\"pct_poverty\"],\n", |
| 175 | + " extensive_variables=[\"EMP_MALE\"],\n", |
| 176 | + ")" |
172 | 177 | ] |
173 | 178 | }, |
174 | 179 | { |
|
200 | 205 | } |
201 | 206 | ], |
202 | 207 | "source": [ |
203 | | - "fig, ax = plt.subplots(1,2, figsize=(14,7))\n", |
| 208 | + "fig, ax = plt.subplots(1, 2, figsize=(14, 7))\n", |
204 | 209 | "\n", |
205 | | - "results.plot('EMP_MALE', scheme='quantiles', ax=ax[0])\n", |
206 | | - "tracts.plot('EMP_MALE', scheme='quantiles', ax=ax[1])\n", |
| 210 | + "results.plot(\"EMP_MALE\", scheme=\"quantiles\", ax=ax[0])\n", |
| 211 | + "tracts.plot(\"EMP_MALE\", scheme=\"quantiles\", ax=ax[1])\n", |
207 | 212 | "\n", |
208 | | - "ax[0].set_title('interpolated')\n", |
209 | | - "ax[1].set_title('original')\n", |
| 213 | + "ax[0].set_title(\"interpolated\")\n", |
| 214 | + "ax[1].set_title(\"original\")\n", |
210 | 215 | "for ax in ax:\n", |
211 | | - " ax.axis('off')\n", |
212 | | - "fig.suptitle('Male Employment (extensive)')" |
| 216 | + " ax.axis(\"off\")\n", |
| 217 | + "fig.suptitle(\"Male Employment (extensive)\")" |
213 | 218 | ] |
214 | 219 | }, |
215 | 220 | { |
|
241 | 246 | } |
242 | 247 | ], |
243 | 248 | "source": [ |
244 | | - "fig, ax = plt.subplots(1,2, figsize=(14,7))\n", |
| 249 | + "fig, ax = plt.subplots(1, 2, figsize=(14, 7))\n", |
245 | 250 | "\n", |
246 | | - "results.plot('pct_poverty', scheme='quantiles', cmap='magma', ax=ax[0])\n", |
247 | | - "tracts.plot('pct_poverty', scheme='quantiles', cmap='magma', ax=ax[1])\n", |
| 251 | + "results.plot(\"pct_poverty\", scheme=\"quantiles\", cmap=\"magma\", ax=ax[0])\n", |
| 252 | + "tracts.plot(\"pct_poverty\", scheme=\"quantiles\", cmap=\"magma\", ax=ax[1])\n", |
248 | 253 | "\n", |
249 | | - "ax[0].set_title('interpolated')\n", |
250 | | - "ax[1].set_title('original')\n", |
| 254 | + "ax[0].set_title(\"interpolated\")\n", |
| 255 | + "ax[1].set_title(\"original\")\n", |
251 | 256 | "for ax in ax:\n", |
252 | | - " ax.axis('off')\n", |
253 | | - "fig.suptitle('Poverty Rate (intensive)')" |
| 257 | + " ax.axis(\"off\")\n", |
| 258 | + "fig.suptitle(\"Poverty Rate (intensive)\")" |
254 | 259 | ] |
255 | 260 | }, |
256 | 261 | { |
|
308 | 313 | ], |
309 | 314 | "source": [ |
310 | 315 | "from quilt3 import Package\n", |
| 316 | + "\n", |
311 | 317 | "p = Package.browse(\"rasters/nlcd\", \"s3://spatial-ucr\")\n", |
312 | 318 | "p[\"nlcd_2011.tif\"].fetch()" |
313 | 319 | ] |
|
329 | 335 | } |
330 | 336 | ], |
331 | 337 | "source": [ |
332 | | - "results = masked_area_interpolate(raster=\"nlcd_2011.tif\", \n", |
333 | | - " source_df=tracts, \n", |
334 | | - " target_df=zip_codes, \n", |
335 | | - " intensive_variables=['pct_poverty'], \n", |
336 | | - " extensive_variables=['EMP_MALE'])" |
| 338 | + "results = masked_area_interpolate(\n", |
| 339 | + " raster=\"nlcd_2011.tif\",\n", |
| 340 | + " source_df=tracts,\n", |
| 341 | + " target_df=zip_codes,\n", |
| 342 | + " intensive_variables=[\"pct_poverty\"],\n", |
| 343 | + " extensive_variables=[\"EMP_MALE\"],\n", |
| 344 | + ")" |
337 | 345 | ] |
338 | 346 | }, |
339 | 347 | { |
|
365 | 373 | } |
366 | 374 | ], |
367 | 375 | "source": [ |
368 | | - "fig, ax = plt.subplots(1,2, figsize=(14,7))\n", |
| 376 | + "fig, ax = plt.subplots(1, 2, figsize=(14, 7))\n", |
369 | 377 | "\n", |
370 | | - "results.plot('EMP_MALE', scheme='quantiles', ax=ax[0])\n", |
371 | | - "tracts.plot('EMP_MALE', scheme='quantiles', ax=ax[1])\n", |
| 378 | + "results.plot(\"EMP_MALE\", scheme=\"quantiles\", ax=ax[0])\n", |
| 379 | + "tracts.plot(\"EMP_MALE\", scheme=\"quantiles\", ax=ax[1])\n", |
372 | 380 | "\n", |
373 | | - "ax[0].set_title('interpolated')\n", |
374 | | - "ax[1].set_title('original')\n", |
| 381 | + "ax[0].set_title(\"interpolated\")\n", |
| 382 | + "ax[1].set_title(\"original\")\n", |
375 | 383 | "for ax in ax:\n", |
376 | | - " ax.axis('off')\n", |
377 | | - "fig.suptitle('Male Employment (extensive)')" |
| 384 | + " ax.axis(\"off\")\n", |
| 385 | + "fig.suptitle(\"Male Employment (extensive)\")" |
378 | 386 | ] |
379 | 387 | }, |
380 | 388 | { |
|
406 | 414 | } |
407 | 415 | ], |
408 | 416 | "source": [ |
409 | | - "fig, ax = plt.subplots(1,2, figsize=(14,7))\n", |
| 417 | + "fig, ax = plt.subplots(1, 2, figsize=(14, 7))\n", |
410 | 418 | "\n", |
411 | | - "results.plot('pct_poverty', scheme='quantiles', cmap='magma', ax=ax[0])\n", |
412 | | - "tracts.plot('pct_poverty', scheme='quantiles', cmap='magma', ax=ax[1])\n", |
| 419 | + "results.plot(\"pct_poverty\", scheme=\"quantiles\", cmap=\"magma\", ax=ax[0])\n", |
| 420 | + "tracts.plot(\"pct_poverty\", scheme=\"quantiles\", cmap=\"magma\", ax=ax[1])\n", |
413 | 421 | "\n", |
414 | | - "ax[0].set_title('interpolated')\n", |
415 | | - "ax[1].set_title('original')\n", |
| 422 | + "ax[0].set_title(\"interpolated\")\n", |
| 423 | + "ax[1].set_title(\"original\")\n", |
416 | 424 | "for ax in ax:\n", |
417 | | - " ax.axis('off')\n", |
418 | | - "fig.suptitle('Poverty Rate (intensive)')" |
| 425 | + " ax.axis(\"off\")\n", |
| 426 | + "fig.suptitle(\"Poverty Rate (intensive)\")" |
419 | 427 | ] |
420 | 428 | }, |
421 | 429 | { |
|
469 | 477 | } |
470 | 478 | ], |
471 | 479 | "source": [ |
472 | | - "emp_results = glm(raster=\"nlcd_2011.tif\",source_df=tracts, target_df=zip_codes, variable='EMP_MALE', )" |
| 480 | + "emp_results = glm(\n", |
| 481 | + " raster=\"nlcd_2011.tif\",\n", |
| 482 | + " source_df=tracts,\n", |
| 483 | + " target_df=zip_codes,\n", |
| 484 | + " variable=\"EMP_MALE\",\n", |
| 485 | + ")" |
473 | 486 | ] |
474 | 487 | }, |
475 | 488 | { |
|
501 | 514 | } |
502 | 515 | ], |
503 | 516 | "source": [ |
504 | | - "fig, ax = plt.subplots(1,2, figsize=(14,7))\n", |
| 517 | + "fig, ax = plt.subplots(1, 2, figsize=(14, 7))\n", |
505 | 518 | "\n", |
506 | | - "emp_results.plot('EMP_MALE', scheme='quantiles', ax=ax[0])\n", |
507 | | - "tracts.plot('EMP_MALE', scheme='quantiles', ax=ax[1])\n", |
| 519 | + "emp_results.plot(\"EMP_MALE\", scheme=\"quantiles\", ax=ax[0])\n", |
| 520 | + "tracts.plot(\"EMP_MALE\", scheme=\"quantiles\", ax=ax[1])\n", |
508 | 521 | "\n", |
509 | | - "ax[0].set_title('interpolated')\n", |
510 | | - "ax[1].set_title('original')\n", |
| 522 | + "ax[0].set_title(\"interpolated\")\n", |
| 523 | + "ax[1].set_title(\"original\")\n", |
511 | 524 | "for ax in ax:\n", |
512 | | - " ax.axis('off')\n", |
513 | | - "fig.suptitle('Male Employment (extensive)')" |
| 525 | + " ax.axis(\"off\")\n", |
| 526 | + "fig.suptitle(\"Male Employment (extensive)\")" |
514 | 527 | ] |
515 | 528 | }, |
516 | 529 | { |
|
536 | 549 | } |
537 | 550 | ], |
538 | 551 | "source": [ |
539 | | - "pov_results = glm(raster=\"nlcd_2011.tif\",source_df=tracts, target_df=zip_codes, variable='pct_poverty', )" |
| 552 | + "pov_results = glm(\n", |
| 553 | + " raster=\"nlcd_2011.tif\",\n", |
| 554 | + " source_df=tracts,\n", |
| 555 | + " target_df=zip_codes,\n", |
| 556 | + " variable=\"pct_poverty\",\n", |
| 557 | + ")" |
540 | 558 | ] |
541 | 559 | }, |
542 | 560 | { |
|
568 | 586 | } |
569 | 587 | ], |
570 | 588 | "source": [ |
571 | | - "fig, ax = plt.subplots(1,2, figsize=(14,7))\n", |
| 589 | + "fig, ax = plt.subplots(1, 2, figsize=(14, 7))\n", |
572 | 590 | "\n", |
573 | | - "pov_results.plot('pct_poverty', scheme='quantiles', cmap='magma', ax=ax[0])\n", |
574 | | - "tracts.plot('pct_poverty', scheme='quantiles', cmap='magma', ax=ax[1])\n", |
| 591 | + "pov_results.plot(\"pct_poverty\", scheme=\"quantiles\", cmap=\"magma\", ax=ax[0])\n", |
| 592 | + "tracts.plot(\"pct_poverty\", scheme=\"quantiles\", cmap=\"magma\", ax=ax[1])\n", |
575 | 593 | "\n", |
576 | | - "ax[0].set_title('interpolated')\n", |
577 | | - "ax[1].set_title('original')\n", |
| 594 | + "ax[0].set_title(\"interpolated\")\n", |
| 595 | + "ax[1].set_title(\"original\")\n", |
578 | 596 | "for ax in ax:\n", |
579 | | - " ax.axis('off')\n", |
580 | | - "fig.suptitle('Poverty Rate (intensive)')" |
| 597 | + " ax.axis(\"off\")\n", |
| 598 | + "fig.suptitle(\"Poverty Rate (intensive)\")" |
581 | 599 | ] |
582 | 600 | }, |
583 | 601 | { |
|
0 commit comments