Is it possible to get OSM data of streets from previous years?

68 views Asked by At

I'm currently enrolled in a Data Science course and am working on a project that examines the evolution of urban complexity. My goal is to analyze and compare the visualizations and data from OpenStreetMap (OSM) for Charlotte, NC, focusing on the data from February 8, 2020, and February 8, 2024. Is there a way to attain the data from the past?

I have successfully downloaded the OSMnx package, not sure what to do next.

1

There are 1 answers

0
Nick ODell On

Yes, it is possible to view the state of OSM as it existed at a specific point in time in osmnx by using attic data.

In order to request this data, you need to change overpass_settings to request data from a specific date.

Example:

import osmnx as ox

# Must be an overpass instance which supports attic
ox.settings.overpass_endpoint = "https://overpass-api.de/api"

def query_year(coordinate, year):
    date = f'{year}-01-01T00:00:00Z'
    # Request attic data
    ox.settings.overpass_settings = '[out:json][timeout:{timeout}][date:"' + date + '"]{maxsize}'
    graph = ox.graph.graph_from_point(coordinate, dist=1000)
    # Restore old settings
    ox.settings.overpass_settings = '[out:json][timeout:{timeout}]{maxsize}'
    return graph

Using this function, and ox.plot.plot_graph(), I made an animation of how the road network in downtown Boulder changed over the course of 8 years. This is an example of something you could use attic data for.

road animation

This example uses ox.graph.graph_from_point(), but every function which queries data from Overpass can use this technique to get attic data. Here is a list of functions which support this:

  • osmnx.features.features_from_address()
  • osmnx.features.features_from_bbox()
  • osmnx.features.features_from_place()
  • osmnx.features.features_from_point()
  • osmnx.features.features_from_polygon()
  • osmnx.graph.graph_from_address()
  • osmnx.graph.graph_from_bbox()
  • osmnx.graph.graph_from_place()
  • osmnx.graph.graph_from_point()
  • osmnx.graph.graph_from_polygon()

This technique comes with a few caveats:

  1. There is no way to distinguish "this road was built in 2020 and immediately mapped" from "this road was built in 1950, but not added to the OSM database until 2020." This is why the OSM project calls this "attic data" rather than "historical data."
  2. This only works if the Overpass endpoint supports attic data, and not all of them do. At the time of writing, the default endpoint, https://overpass-api.de/api, supports attic data, but this might not be true in the future. You can consult this list to find an endpoint which supports attic data.
  3. Since ox.settings.overpass_settings is global, changing the query date in one function changes it for all functions. For that reason, the code sample above restores original settings as soon as it is done querying.