Azavea Atlas

Maps, geography and the web

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.

 

 

2015 State Legislative Vacancy Report

2015 was a turbulent year for state legislatures in the US. It is not unheard of for legislators to step down mid-term, however the past year saw a whopping 88 seats vacated by State Senators and Representatives. When an elected official steps down before their term is over, the seat is either filled by an appointment or a special election. Twenty-three states appoint successors, either through the Governor’s office, or by the party last occupying the seat. A slightly greater number of states hold special elections to fill empty seats. In this case, a district’s constituents are without representation until the newly elected official takes office, which is often months after the seat was first vacated.

Why all the Change?

A legislator may choose to leave their post for various reasons. In 2015, the top reason for open seats was due to an official being appointed or elected to an alternate position. For example, a
A graph depicting the reasons for State Legislative VacanciesGovernor or Mayor may call on a State Senator to leave the legislature to serve in their cabinet. This appointment may then set off a series of special elections, as it is common for a State Representative to run for that open State Senate position (typically referred to as a “promotion” to a higher legislature). Similarly, a legislator may leave their seat to run in another election. This happened in February in Texas SD-26 when Senator Leticia Van de Putte left her seat to run for Mayor of San Antonio. Jose Menendez, an incumbent in Texas HD-124 won that election, setting off yet another special election for his newly vacant house seat.

The second most popular reason for an elected official retiring in 2015 was to accept a job in the private sector. Some state legislatures are considered “part-time” and many officials carry additional jobs. New Hampshire’s Rockingham 20 House District Representative Dennis B. Sweeney held a zero percent voting record four months into his 2015 term. He ultimately stepped down because his work schedule prevented him from attending sessions.

Repeat Offenders

So, which states had the most special elections in 2015? 2 or 3 elections might be typical for a state in any given year, but in 2015 Georgia held a monumental 12 special elections–a recent all time high. That is the more than any state going back to 2011. Interestingly, Georgia was the winner that year as well, with 11 polls for vacated positions. Coming up second this year was Pennsylvania, with 8 special elections, 6 of which occurred in the second half of the year.

A graph showing US States that had the most special elections in 2015

Comparatively

88 vacant seats may seem like a lot. But how does it compare to years past? In the previous 4 years, 2011 was the only year to exceed 2015 in terms of vacant seats up for special election, with a grand total of 94. This actually makes sense. In 4 year election cycles, the year before a Presidential election (in which many other states also hold state elections) typically sees a lot of activity.
2015 Vacancies compared to the past 4 yearsThis is due in part to legislators resigning seats to run for different, open ones. The previous years, (2010 and 2014) also saw mid-term elections during which new administrations may have taken office and appointed Senators and Representatives to cabinet positions. If appointments take time, the open seats they create may not be reflected until the following year.

2013 also saw a high number of vacant seats filled with special elections, with a total of 84. Because odd years see very few state elections, Special Elections must be called, rather than an even-year option of waiting until the next scheduled general election. Many state laws specify that if a seat becomes vacant within a few months of a scheduled, general election, the seat will wait to be filled at that time. This unfortunately leaves a district without representation, but it does save the state a significant amount of money. Special elections often cost hundreds of thousands of dollars and see very low turnout from the electorate.

Moving Forward

Wondering if 2016 will be more of the same? Heading into the second month of the year, 34 state legislative seats are already open. 20 special elections have been scheduled, and 3 remain unscheduled at this time. At least 6 more open seats are awaiting appointment. And you can probably bet there will be more.

The Cicero database keeps track of Special Elections for all 50 states in the US, at the National, State, and even local levels for our largest cities. If you’re interested in learning more, give us a shout via email (cicero@azavea.com) or Twitter (@CiceroAPI). We’d love to talk elections with you!

 

Announcing Azavea’s Nonprofit Map Readiness Program

Where are more potential clients? How do we prioritize which service locations to improve? What programs do we choose to fund? What is the demographic breakdown of our donors? If you’re a nonprofit, you’ve probably asked yourself these questions many times. And the answer you’ve found time after time requires data. But with busy schedules and tight budgets, gathering, cleaning, analyzing, and sharing data can be a burden.

We here at Azavea understand the difficulties nonprofits face when working with data. We’ve partnered with nonprofits in the Philadelphia region for fifteen years to help them better understand their data and make compelling visualizations to share internally and with the public. As part of that continued effort we’re proud to unveil our new Map Readiness Program.

Map readiness logo with charts, a report, and a graph

Azavea’s Map Readiness Program aims to help nonprofits assess their data, improve processes, find opportunities for analysis, and become more data-driven organizations. For a low one-time fee our Data Analytics team will work with you to understand your nonprofit’s aspirations, challenges, and opportunities. The Map Readiness Program will produce a report tailored to your organization’s specific needs and circumstances with recommendations, resources, project ideas, and actionable next steps. Think of it as a roadmap to becoming a more data-driven organization, drawn just for you. With the Map Readiness Program Report in hand, you’ll be able to better understand how to use your data to improve your operations and reach the people and places you serve.

To learn more about the Azavea Map Readiness Program, visit analytics.azavea.com and fill out the “More Information” request form.