ST_OverpassDownloader

Signatures

ST_OverpassDownloader(VARCHAR query, VARCHAR path);
ST_OverpassDownloader(VARCHAR query, VARCHAR path, BOOLEAN delete);
ST_OverpassDownloader(VARCHAR query, VARCHAR path, BOOLEAN delete, VARCHAR network);

Description

Extract OSM data from Overpass API server and save the result into an .osm file which the place and the name are defined in the path. If the delete parameter is equal to true, then the .osm file will be overwritten if it already exists.

Where:

  • query : the Overpass query, as string,

  • path : the path of the file to store the result,

  • delete : a boolean to delete the file if exist

  • network : network options as 'proxyhost=? proxyport=? endpoint=?'

Examples

In the example below, we want to collect all the schools from the city of Nantes (West of France, which unique identifier is the INSEE code = 44109). The result will be saved in the nantes_schools.geojson file.

SELECT ST_OverpassDownloader('area ["admin_level"="8"] ["ref:INSEE"="44109"];
                              node ["amenity"="school"] (area);
                              out geom;', 
                             '/home/user/nantes_schools.geojson', true);

Now you can open the resulting nantes_schools.geojson file in your favorite GIS app. You should see the data below

See also

OSMRead, ST_OSMMapLink, ST_OSMDownloader, ST_AsOverpassBbox