Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS API for Python

Download the samples Try it live

Data Summarization - Construction permits, part 2/2

In the "Explore and analyze construction permits" notebook, we explored your data and learned a little about the spatial and temporal trends of permit activity in Montgomery County. In this lesson, we'll move beyond exploration and run spatial analysis tools to answer specific questions that can't be answered by the data itself. In particular, we want to know why permits spiked in Germantown in 2011 and predict where future permit spikes - and, by extension, future growth - are likely to occur.

First, we'll aggregate the points by ZIP Code. We'll enrich each ZIP Code with demographic information and learn more about the demographic conditions that led to such rapid growth in such a short time. Once you determine why growth occurred where and when it did, we'll locate other ZIP Codes with similar demographic characteristics to predict future growth.

Aggregate points

In [1]:
from arcgis import GIS
from arcgis import __version__
In [2]:
gis = GIS()
Enter password: ········
In [3]:
gis._url = ""
In [4]:
permit_agg_by_zip = gis.content.get("b864539b1f3342cbab716c94742a8d6d")
Feature Layer Collection by DavidJVitale
Last Modified: September 18, 2020
0 comments, 5 views

Aggregation results

In [5]:
agg_map ='Maryland')
In [6]:

The new layer looks like a point layer, but it's actually a polygon layer with a point symbology. Each point represents the number of permits per ZIP Code area. Larger points indicate ZIP Codes with more permits.

In [12]:
import pandas as pd
In [ ]:
sdf = pd.DataFrame.spatial.from_layer(permit_agg_by_zip.layers[0])
In [ ]:
In [ ]:
In [ ]:

Review some basic statistics about the data.

In [ ]:
In [ ]:
In [ ]:
In [ ]:
agg_layer = permit_agg_by_zip.layers[0]

Although most of the large point symbols on the map are in the southeast corner, near Washington, D.C., there are a few large points in the northwest. In particular, there is a very large circle in the ZIP Code located in Clarksburg. (If you're using different ZIP Code data, this area may be identified as ZIP Code 20871 instead.) The ZIP code has 948 permits. Additionally, this area geographically corresponds to the hot spot you identified in the previous lesson. This ZIP Code is one that you'll focus on when you enrich your layer with demographic data.

Enrich the data

Are there demographic characteristics about the Clarksburg ZIP Code that contributed to its high growth? If so, are there other areas with those characteristics that may experience growth in the future? To answer these questions, you'll use the Enrich Data analysis tool. This tool adds demographic attributes of your choice to your data. Specifically, you'll add Tapestry information to each ZIP Code. Tapestry is a summary of many demographic and socioeconomic variables, including age groups and lifestyle choices. It'll teach you more about the types of people who live in your area of interest and help you better understand the reasons why growth happened where it did.

In [8]:
from arcgis.features.enrich_data import enrich_layer
from datetime import datetime as dt
In [9]:
enrich_aggregate = gis.content.get("550e3cee8e9f45488d79d3772905d300")
Feature Layer Collection by DavidJVitale
Last Modified: September 18, 2020
0 comments, 0 views
In [10]:
agg_lyr = enrich_aggregate.layers[0]
In [13]:
sdf = pd.DataFrame.spatial.from_layer(agg_lyr)
In [14]:
OBJECTID Point_Count ZIP_CODE PO_NAME STATE POPULATION SQMI AnalysisArea ID sourceCountry ENRICH_FID aggregationMethod populationToPolygonSizeRating apportionmentConfidence HasData TSEGNAME SHAPE
0 1 6 20012 Washington DC 14652 2.36 2.356814 0 US 1 BlockApportionment:US.BlockGroups 2.191 2.576 1 City Lights {"rings": [[[-77.026627, 38.9845580000001], [-...
1 2 1 20783 Hyattsville MD 48592 6.26 6.248092 1 US 2 BlockApportionment:US.BlockGroups 2.191 2.576 1 NeWest Residents {"rings": [[[-76.9414389999999, 39.02912600000...
2 3 1 20812 Glen Echo MD 219 0.19 0.191061 2 US 3 BlockApportionment:US.BlockGroups 2.191 2.576 1 Urban Chic {"rings": [[[-77.13843, 38.9684140000001], [-7...
3 4 1145 20814 Bethesda MD 30017 5.17 5.168331 3 US 4 BlockApportionment:US.BlockGroups 2.191 2.576 1 Metro Renters {"rings": [[[-77.094363, 39.0225080000001], [-...
4 5 586 20815 Chevy Chase MD 30001 5.35 5.360828 4 US 5 BlockApportionment:US.BlockGroups 2.191 2.576 1 Top Tier {"rings": [[[-77.0635971999999, 39.0119754], [...
In [15]:
enrich_aggregate_map ='Maryland')
In [16]: