Overture/Athena

From OpenStreetMap Wiki
Jump to navigation Jump to search

Athena is AWS service that allows to run queries over datasets in cloud. It costs 5.00 USD per Terabytes for DataScannedInTB in US West (Oregon). See pricing for details.

AWS Setup

Follow instructions to setup AWS account with access to Overture Maps dataset within Athena.

Make sure you are running Athena in 'us-west-2' "Oregon" region. Otherwise you will see error "Error fetching Associated databases User: {username} is not authorized to perform: glue:GetDatabases on resource: arn:aws:glue:us-west-1:913550007193:catalog because no resource-based policy allows the glue:GetDatabases action".

Quering data

  1. Open Athena UI and create new query editor.
  2. Select previously created Overture dataset. You can see snapshots of OvertureMap dataset in format 'v{YYYY}_{MM}_{DD}_{REVISION}'. Use the latest one to get most recent data.

Query sample 1

Calculate length of all roads in Japan by type:

WITH boundary(geom) as (SELECT ST_GeomFromBinary(geometry) as geom
                          FROM v2024_09_18_0
                         WHERE type = 'division_area'
                           AND subtype = 'country'
                           AND names.primary = 'Japan') -- Find Japan country boundary
SELECT class,
       sum(ST_Length(to_spherical_geography(ST_GeomFromBinary(geometry)))) as total_length,
       format('%,.0f', sum(ST_Length(to_spherical_geography(ST_GeomFromBinary(geometry))))) as total_length_str
  FROM v2024_09_18_0
  -- Filter by country boundary
  JOIN boundary on ST_Contains(boundary.geom, ST_GeomFromBinary(geometry)) = true
 WHERE type = 'segment' AND subtype = 'road'
 GROUP BY class
 ORDER BY total_length DESC;

Time to execute: 5-6 min.

Output:

class total_length_str
residential 487,958,832
unclassified 455,126,578
path 209,017,201
track 201,493,984
... ...