GEOG: 585 | FOSS Web Mapping | LA Public Amenity Accessibility
Select Heatmap Data Source

About this map

This page shows the accessibility of various commidities in Los Angeles via public transportation networks. Click on the map to calculate the number of amenities in the area based on roughly estimated travel time*. Additional layers can be expossed from the control in the top-right of the map. Clicking on an ameities icon while display a popup with details about that amenity.

How the amenity numbers are caclulated

  1. Clicking on the map triggers a leaflet map click event, the coordinates of which are used in a Javascript function.
  2. Background GeoJSON data containing the all the nodes on the bus route network topology is accessed, the Turf.js nearest function finds the ID of the closest to the map click event. A temporary marker is placed on the map at the location of the node.
  3. The ID of the node is sent in a GET request to the Django webserver.
  4. Django uses the node ID sent with the request in order to execute an SQL command on a PostgreSQL database server. The command is executed via specific Django functions that protect against SQL injection attacks.
  5. The Postgres server creates temporary tables in order to store intermediary data. The first task it builds a list of all the nodes in the network topology within the maximum distance (cost) of the node ID that was sent to the server using the pgRouting drivingDistance function. Secondly the server performs a PostGIS concaveHull calculation using a subset of nodes for each of the distances needed, (4000, 8000, and 12000 meters).
  6. The Django recieves each of the concave hull polygons as part of GeoDjango models, which are then serialized into GeoJSON feature collection format.
  7. The GeoJSON data is sent back to the client as a reponse to the GET request.
  8. The client loops through all of the amenities using the Turf.js booleanWithin function and counts the number in each of the concave hull polygons.
  9. The final results are added to a popup which is opened at the previously placed marker.

Caveats and room for improvement

*Travel times assume a uniform travel speed of 800 meters/min (~30 mph). The network topology assumes that buses can stop at any node, can turn in any direction, are available on demand and can travel in any direction along the route. Additionally there is no cosideration taken for a person's ability to walk from places along the network route.

An alpha shape polygon would be a more accurate representation of travel times than a concave hull because it allows for "holes" inside of the geometry. I stuck with the concave hulls because in my testing of the pgRouting alphaShape function requires a spoon_radius variable that requires a lot of manual tweaking in order to get a decent polygon, which is not very useful when fetching polygons that could be of any variable size.

A more accurate representation of areas accessible via bus transportation would likely draw a disolved buffer around the bus stops, based on how long it would take to reach the stop (i.e. if a bus ride took 3 minutes, a buffer of 2 minutes walking would represent the "5 minute" accessible area). Overall the network topology would require a lot more work in order to make it accurate, as such it should be taken as a proof of concept and not used as an actual measurment.

This application could be expanded further by providing a list of amenities within the travel area, rather than just a count. The OSM data is currently only a snapshot of the data as it existed in August 2021, it would likely be useful to automate pulling in new/edited OSM in some form. It would also easily be possible to extend the map by including more categories of amenities or by including the entire LA county area.

Video