Select to view content in your preferred language

Add data from URL from Overpass Turbo not working

351
4
a month ago
KarenFergason1
New Contributor II

I am trying to 'add a layer from URL' to my webmap using an API from OpenStreetMap (OSM). OSM recommends using Overpass Turbo, which is a web based data mining tool designed for their system: https://overpass-turbo.eu/

Overpass Turbo allows the user to run queries using keywords which are defined here: Map Features. For example, I would like to find cities in Haiti so the query is written as:

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“place=city in haiti”
*/
[out:json][timeout:25];
// fetch area “haiti” to search in
{{geocodeArea:haiti}}->.searchArea;
// gather results
node["place"="city"](area.searchArea);
// print results
out geom;

This query runs successfully in Overpass Turbo and returns points corresponding to cities in Haiti. I then click the Export button which opens a pop-up with several options, none of which work with "Add layer from URL" in AGOL. For example, I tried selecting "raw data directly from Overpass API" which opens a new browser tab with the data. I copied this URL and tried adding it as a layer as a geojson, but I get an error: "Unable to add layer. The layer cannot be added to the map." For reference, I am able to download the data and add it as a hosted layer but I am trying to do this directly from a URL so I don't have to host copies of the OSM data.

I have tried troubleshooting this on chatGPT and it seems like the issue maybe json vs geojson formatting. I created a python notebook and tried writing some code to correct this but have been unsuccessful. At this point I feel like I'm getting too far down a rabbit hole for something that should be fairly straight forward. 

Is there a way to use Overpass Turbo to create a URL which can be read into geojson layer in AGOL?

 

0 Kudos
4 Replies
jcarlson
MVP Esteemed Contributor

Adding from a URL won't really work with Overpass using the method you're trying. There might be a way to do this with a Data Pipeline, perhaps? Why not just use Esri's OpenStreetMap feature layers from the Living Atlas? Pretty sure they have city nodes in there somewhere.

- Josh Carlson
Kendall County GIS
0 Kudos
KarenFergason1
New Contributor II

Thank you Josh. I understand that some layers like cities are available in the Living Atlas, but I was only providing that as an example. My assignment is to query OSM for different kinds of data that are not included in Living Atlas (I have searched for these already).  

I am not a programmer so these kinds of queries are new for me. As I understand it, Overpass Turbo is intended to query OSM using an API to get data in a geojson format (among others). Can I only get the data in geojson format if I download the data, not if queried using a URL as I am trying to do? I had assumed this was a typical sort of interface between OSM and AGOL, but perhaps not.

I will continue searching for other ways to make this query work such as data pipeline, but I would still love to know if anyone has a direct solution. 

0 Kudos
jcarlson
MVP Esteemed Contributor

We also run into lots of cases where Esri's OSM data falls short of what we need. We've gone the route of using osm2pgsql with osmium to scrape a daily extract of OSM data into a standalone database, but we're using the data locally more than via the web.

We do have a few layers that are useful to have in a web setting, but for those, we just have a hosted layer that automatically updates when our standalone database refreshes. Probably a bit more trouble than its worth unless you've got a lot of OSM features you need in a web map.

I've only played with Pipelines a little, but it does look like you could get it to work. Here's me using a query to pull bench nodes for my area.

jcarlson_0-1721315269950.png

 

- Josh Carlson
Kendall County GIS
0 Kudos
KarenFergason1
New Contributor II

Thanks again Josh, could you provide a link to the application you are using in the screenshot?

0 Kudos