Filter output tags (json format)

this query selects two “alpine_hut” with some tags,

[out:json][timeout:30];(
  node(1085925753);node(6866498286);
); out body;

I would like to filter tags of interest to me: name, ele, tourism, website
and remove all others (phone, fee, addr:, contact:)

I know I can create a csv but it’s not good for my purpose;
I want to keep the data in json format

any suggestions?

foreach
{
  convert MyType osm_type = type(), ::id= id(), ::geom = geom(), 
                 tourism = t["tourism"],  
                 name = t["name"], 
                 ele = t["ele"], 
                 website = t["website"]; 
  out geom; 
};

And you can use comma for multiple objects overpass turbo

2 Likes

Thanks Kovoschiz for the reply
I had tried convert statement but it discards geometry (lat/lon info)
the results are not visible on the maps :frowning:

https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#The_statement_convert

original output:

{
“type”: “node”,
“id”: 1085925753,
“lat”: 43.7961269,
“lon”: 11.7898353,

}

output with convert:

{
“type”: “MyType”,
“id”: 1085925753,
“geometry”: {
“type”: “Point”,
“coordinates”: [ 11.7898353, 43.7961269 ]
},

}

ok with convert I can filter the tags and I get a json. . . but I don’t see the results on the map

it’s also strange because latitude & longitude data exists (in different format :confused: )
you can try this request with and without convert statement:
[overpass turbo]

json data differs in location format

thanks for the suggestions

FYI The foreach command isn’t required.

[out:json];
node(id:1085925753,6866498286);
convert MyType
osm_type = type(),
::id= id(),
::geom = geom(),
tourism = t[“tourism”],
name = t[“name”],
ele = t[“ele”],
website = t[“website”];
out geom;

1 Like