Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS API for Python

Download the samples Try it live

Which college district has the fewest low-income families?

A pilot program was run by a local cable operater in the county to provide low-cost computers and Internet access to low-income families with kids in high school. This showed a marked improvement in school performance for these kids, and the program has brought the company a fair amount of positive publicity and goodwill in the community.

Company officials now want to set up a similar program for community college students. The company provides Internet access to the five community college districts in the county, and officials are aware that the colleges are under a lot of pressure—they are facing funding cuts at the same time as increased demand for enrollment. To try to improve the situation the colleges are turning more and more to distance learning, primarily via the Internet. By providing computers and Internet access, the cable company can enable more low-income students to take advantage of online classes.

This case study uses ArcGIS API for Python to find districts that have the fewest low income families in order to empower these students.

We will use summarize_within tool to get the number of low income families within each community district. We will also visualize this using the map widget.

Connect to your ArcGIS Online organization

We first establish a connection to our organization which could be an ArcGIS Online organization or an ArcGIS Enterprise. To be able to run the code using ArcGIS API for Python, we will need to provide credentials of a user within an ArcGIS Online organization.

In [1]:
from arcgis.gis import GIS

import pandas as pd
In [2]:
gis = GIS("https://geosaurus.maps.arcgis.com", "arcgis_python", "P@ssword123")

Get data for analysis

In [4]:
san_diego_data = gis.content.search('title:SanDiegoColleges', 'Feature layer')
In [5]:
san_diego_data
Out[5]:
[<Item title:"SanDiegoColleges" type:Feature Layer Collection owner:arcgis_python>]
In [6]:
from IPython.display import display

for item in san_diego_data:
    display(item)
SanDiegoColleges
Community College DistrictFeature Layer Collection by arcgis_python
Last Modified: February 17, 2019
0 comments, 6 views
In [7]:
san_diego_item = san_diego_data[0] # get first item from the list of items
In [8]:
for lyr in san_diego_item.layers:
    print(lyr.properties.name)
Community_College_Dist
census_tract_income

Since the item is a Feature Layer Collection, accessing the layers property will give us a list of Feature Layers.

In [9]:
community_college_dist = san_diego_item.layers[0]
In [10]:
census_tract_income = san_diego_item.layers[1] 
In [11]:
m1 = gis.map('San Diego')
m1
Out[11]:
In [12]:
m1.add_layer(community_college_dist)
In [13]:
m2 = gis.map('San Diego')
m2
Out[13]: