Azavea Atlas

Maps, geography and the web

Cicero Sponsors #HacktheVotePA

Philly Tech Week is upon us, and the Pennsylvania NewsMedia Association is hosting an exciting hackathon for the occasion. #HacktheVotePA is a day-long event geared toward voter education and engagement, causes that are near and dear to the Cicero team’s heart.

4 hands holding the letters that form the word "vote"

For this reason, we are thrilled to announce that Cicero will be sponsoring #HacktheVotePA, and will provide 2,000 free API credits to all who sign up during the hackathon on May 5th. The Cicero API geocodes addresses, then matches them to legislative districts and officials at the National, State, and even local levels for about 100 of the largest US cities. It also returns comprehensive elected official contact information like office addresses, emails, and social media identifiers. To start using the API, simply visit our free trial page and sign up. You will instantly get 1,000 credits, and as a bonus we’ll add 1,000 more. Check out our documentation, then get hacking!

#HacktheVotePA is happening at the Philadelphia Media Network on May 5th, from 9am-5pm. Tickets are only $10, and you can register for them here. This is a great event, focused on an important cause. We hope to see you there!

 

Announcing our 2016 Summer of Maps Fellows and Projects

Summer of Maps logo

Summer of Maps offers fellowships to GIS and geography students to perform spatial analysis for nonprofit organizations. The program matches non-profit organizations that have spatial analysis and visualization needs with talented students to implement projects over a three-month period during the summer. We are thrilled to announce the 2016 Summer of Maps fellows and the non-profit organizations they will work with. Please join me in congratulating:

Carlos Bonilla, B.A. in Geography and Urban Studies at Temple University, working with:

Annaka Scheeres, B.S. and B.A., Biology and Environmental Studies (Geography Concentration) at Calvin College, working with:

Parker Ziegler, Bachelor of Arts, Geography and Bachelor of Arts, Arabic at Middlebury College, working with:

  • Transportation Alternatives – The Road to Vision Zero: Traffic Crashes and Poverty Level in New York City

  • Ecotrust – Ongoing Change in Portland’s Urban Forest Canopy and Looking Ahead in the 2035 Comprehensive Plan

We are very excited to work with our 2016 Summer of Maps fellows and support them through their work with these nonprofits. Students interested in the 2017 program or nonprofits that would like to submit a project, please visit the Get Involved page of our website. We’re always looking for gracious sponsors for the program. If you would like to sponsor the 2016 program, we welcome you to contact us.

Free Cicero API credits for #DemHack2016!

 

In honor of Apps for Philly Democracy 2016, Cicero is granting twice the free API credits to all who sign up Friday, March 18th through Sunday, March 20th. #DemHack2016 is a weekend-long hackathon thatLogo for Apps for Philly Democracy Hackathon 2016 brings Philadelphians together to discuss how technology can improve democracy in our city. Since this is a cause that is near and dear to our hearts, we’re offering 2,000 free Cicero API credits during the hackathon!

Ok, free stuff is cool, but what can you do with it? The Cicero API geocodes addresses, then matches them to legislative districts and officials at the National, State, and local levels for about 100 of the
largest US cities (including Philadelphia, of course). It also returns comprehensive elected
official contact information like office addresses, emails, and social media identifiers (we recently added Instagram and LinkedIn to our growing list). The API even has a map call that provides you with a configurable boundary map image for each district.

In addition to free credits, the Cicero Team would love to feature any apps coming out of the Hackathon using our API. To sign up, simply visit our free trial page. You will instantly get 2,000 credits, which will be good for a full 6 months. Check out our documentation, then get hacking! We’re excited to see what you come up with.

 

Apply to be a 2016 Summer of Maps Fellow!

Applications are now open for students for 2016 Azavea Summer of Maps. Summer of Maps offers $5000 paid fellowships to student spatial analysts to perform geographic data analysis for non-profit organizations. Students will pick from hand selected, engaging projects submitted by non-profits. We are looking for enthusiastic students with GIS analysis experience to apply.

The schedule for the selection process is below:

  • Weds., Mar 9, 11pm – Deadline for Students to submit applications
  • Late-March – Early April – Top candidates are evaluated through interviews and analysis tasks
  • May 1 – Successful Summer of Maps fellows and Projects will be announced
  • Weds., June 1 – Tues., Aug 23 – Summer of Maps fellows work on spatial analysis projects

What will non-profit organizations receive?

  • Pro bono services from a talented student spatial analyst to geographically analyze data
  • Visualizations of data in new and innovative ways
  • Synthesis of other demographic and geographic data to draw new observations
  • High quality maps that can be used to make a case to funders or support new initiatives

What will students learn?

  • How to design and manage a spatial analysis project that supports the social mission of non-profit organizations
  • New and innovative skills from Azavea mentors
  • Professional work experience implementing a real-world GIS project

Eligibility

This is a paid fellowship program opened to full-time or part-time students. Azavea defines a student as an individual accepted into or enrolled in an accredited post-secondary institution located in the United States, including community colleges, universities, masters, PhD and undergraduate programs. Alternatively, you may be enrolled in an accredited non-U.S. university, but you must have a valid work visa that enables you to work in the United States (we are not able to sponsor you for a visa or provide travel expenses for travel to the U.S.).  If you are accepted into or enrolled in a college or university program as of April 2015, you are eligible to participate in the program, even if you will graduate during the program. You must be available to work at the Azavea office in Philadelphia starting on June 1, 2015.

Azavea may ask you to provide transcripts or other documentation from your accredited institution as proof of enrollment or admission status. You do not need to be in a Geography or GIS program in order to apply, but you should have experience performing analysis using desktop GIS software.

Submit your application now through Wednesday, March 9th, 11pm ET.

How Philadelphians Get To Work: Calculating Mode Share and Dot Density Maps in CartoDB

To view the full screen map of journey to work in Philadelphia, click here.

We’ve seen some great examples of dot density maps that have been made the past few years, notably the excellent map of racial groups released in 2013. Essentially, these maps are created from polygon census shapefiles by randomly distributing points within each polygon based on the total of each attribute being displayed. For example, if 3,000 people live in a Census tract, 3,000 dots will be randomly distributed in the tract. There are plugins in ArcGIS and QGIS to do this, but what about PostGIS and CartoDB?

I thought I’d take a transportation-related dataset, journey to work mode, available in the latest release of the American Community Survey, and visualize that by the census block group in Philadelphia. The journey to work data contains fairly detailed information on the number of people and how they get to work — in this example I’m going to use drove alone, walking, bicycling and public transit. Most of the time if you’re visualizing data with multiple attributes like journey to work, you’d make separate choropleth maps, one for each mode. In this case, the dot density map will represent each transportation mode, with one colored dot for each category of response.

One of the common issues with dot density maps is that they can misrepresent location. Since we don’t have household level data from the Census, each of the dots are randomly distributed within the polygons, not actually placed on the location of the house. Therefore, it’s a good idea to clip out features where you know people do not live. In this case, I clipped out water features from the block group shapefile. One could imagine taking that a step further and clipping to only residential land use or parcels, but that might get a little messy if displaying multiple attributes in smaller polygons. Next, I calculated percentage share for each mode, using the SQL below after loading the data into a PostGIS database (in this case, CartoDB):

UPDATE azavea.phila_blockgroups
SET _14_perc_drovealone = round( round(_14_totalcar_drovealone,1) / round(_14_total,1) * 100, 1) WHERE _14_totalcar_drovealone  > 0

Note that I used the round() function to play nice with the field types in CartoDB and display percentages with one decimal place. I’ll use the calculated mode share percentages that we just made to style an infowindow containing the proportion of each block group using a particular mode share. Next, I’ll have to create that dot density spatial table in CartoDB.

Since CartoDB uses PostGIS to store spatial data, you can write functions directly in the SQL editor and apply them to your datasets. It’s often a bit of a trial and error process, since not every function available in PostGIS is going to work in CartoDB. Stuart Lynn, Map Scientist at CartoDB, came up with a function to create dot density maps in PostGIS. This function can be added to any CartoDB instance or even right in the SQL editor. You can find the dot density function below, which you can just copy, paste, and then run in the Editor:

CREATE OR REPLACE FUNCTION dot_density(g geometry , no_points Integer, max_iter Integer DEFAULT 1000 )
   RETURNS setof geometry AS
 $$
 DECLARE  
     extent GEOMETRY;
     test_point Geometry;
     width    NUMERIC;
     height   NUMERIC;
     x0       NUMERIC;
     y0       NUMERIC;
     xp       NUMERIC;
     yp       NUMERIC;
  no_left  INTEGER;
     points   GEOMETRY[];
 BEGIN       
   extent  := ST_Envelope(g);
   width   := ST_XMax(extent) - ST_XMIN(extent);
   height  := ST_YMax(extent) - ST_YMIN(extent);
   x0    := ST_XMin(extent);
   y0    := ST_YMin(extent);
   no_left := no_points;
   
   LOOP 
     if(no_left=0) THEN
       EXIT;
     END IF;
     
     xp = x0 + width*random();
     yp = y0 + height*random();
     test_point = CDB_LATLNG(yp,xp);
     
     IF(ST_Contains(g, test_point)) THEN
       no_left = no_left - 1;
       RETURN NEXT test_point;
     END IF;
   END LOOP;
  
  
 END
 $$
 LANGUAGE plpgsql VOLATILE

The function finds the extent of each of the polygons in the table, creates random points within that extent, then passes the points through the polygon and keeps them if they fall inside.

Next, I used that dot density function to create a table — with one point for each of the number of people driving, walking, taking public transit, or bicycling to work. The function requires two inputs; the geometry field and the attribute field you are mapping.

select ST_TRANSFORM(dot_density(the_geom,_14_totalcar_drovealone::integer),3857) as the_geom_webmercator, '14drovealone' as mode, 1 as t from azavea.philadelphia_block_groups_with_mode_share

UNION

select ST_TRANSFORM(dot_density(the_geom,_14_totalpublic_transit::integer),3857) as the_geom_webmercator, '14publictransit' as mode, 1 as t from azavea.philadelphia_block_groups_with_mode_share

UNION

select ST_TRANSFORM(dot_density(the_geom,_14_bicycle::integer),3857) as the_geom_webmercator, '14bicycle' as mode, 1 as t from azavea.philadelphia_block_groups_with_mode_share  

UNION

select ST_TRANSFORM(dot_density(the_geom,_14_walked::integer),3857) as the_geom_webmercator, '14walked' as mode, 1 as t from azavea.philadelphia_block_groups_with_mode_share

The result is a table with points in each block group that contain an attribute for the type of journey to work mode. Finally, I used Leaflet to overlay that map with the journey to mode share polygons, with no styling, but applied a highlight on click. The resulting map is below:
In summary, a dot density map can be a cool way to visualize aggregate data and identify spatial patterns, keeping in mind the caveats. In the map of Philadelphia journey to work, one can easily start to identify commuting patterns across the city. In Center City, the map is dominated by walking and public transit use. In University City, there’s a lot of walkers, and a surprising number of people drive alone in Northern Liberties and Fishtown. In Point Breeze, there’s a few pockets with lots of residents commuting by bicycle. You can find the code here.