1

I want to extract some amenity(atm) from a pbf file. Here is what i've found.

osmosis --read-pbf myfile.pbf --tf accept-nodes amenity=atm --write-xml atm.osm

Myfile.pbf is a file for Paris area (France). It's 211Mo.
The atm.osm file is 1.8Go I think it's really big for only ATM of Paris. So is it the good way to extract atm?
I also tried with rarely amenity and it's always a 1.8Go file.
Is there a way to read atm.osm to know if the data is good?
If I'm not on the right way I want to extract ATM from the data to insert it in the future in a database.

  • You are pulling in too much data because you only filter nodes but keep all ways and relations. You have to specify --tf reject-ways --tf reject-relations if you want to ignore ways and relations. – scai May 18 '15 at 17:03
2

I found a different query :

osmosis --read-pbf myfile.pbf --node-key-value keyValueList='amenity.atm' --write-xml atm.osm

I got a 250ko xml file with all the atm. Hope it can help other peolple

| improve this answer | |
  • 1
    Note that this will not extract all ATMs. There are ATMs are tagged with atm=yes (about 100.000 worldwide). This tag is used in combination with amenity=bank and does not only appear on nodes but also on ways and even some relations. – scai May 17 '15 at 19:17
  • so atm=yes are atm in banks? So what is the other query I need to do? – BoumTAC May 17 '15 at 23:31
  • See my answer. – scai May 18 '15 at 17:02
2

Try the following queries:

# read all nodes with amenity=atm or atm=yes, ignore ways and relations
osmosis --read-xml data.osm --tf accept-nodes amenity=atm --tf reject-ways --tf reject-relations --write-xml amenity_atm_nodes.osm
osmosis --read-xml data.osm --tf accept-nodes atm=yes     --tf reject-ways --tf reject-relations --write-xml atm_yes_nodes.osm

# read all ways with amenity=atm or atm=yes, keep only related nodes, ignore relations
osmosis --read-xml data.osm --tf accept-ways  amenity=atm --used-node --tf reject-relations --write-xml amenity_atm_ways.osm
osmosis --read-xml data.osm --tf accept-ways  atm=yes     --used-node --tf reject-relations --write-xml atm_yes_ways.osm

# read all relations with amenity=atm or atm=yes, keep only related ways and nodes
osmosis --read-xml data.osm --tf accept-relations amenity=atm --used-way --tf accept-relations atm=yes --used-node --write-xml amenity_atm_relations.osm
osmosis --read-xml data.osm --tf accept-relations atm=yes     --used-way --tf accept-relations atm=yes --used-node --write-xml atm_yes_relations.osm

# merge all files together
osmosis --rx amenity_atm_nodes.osm --rx atm_yes_nodes.osm \
        --rx amenity_atm_ways.osm --rx atm_yes_ways.osm \
        --rx amenity_atm_relations.osm --rx atm_yes_relations.osm \
        --merge --merge --merge --merge --merge --wx atm.osm

However the second block (the part with the ways) seems to pull in slightly too much data. No idea what I'm doing wrong, maybe someone can fix it. And the syntax is just horrible. Also you can probably speed up things a lot by using pipes instead of calling osmosis again and again for each sub task.

Alternatively you may also think about just using Overpass API. Constructing tag filters with Overpass API is a little simpler and you don't even have to download the whole area beforehand. Here is an example query on overpass turbo:

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“amenity=atm or atm=yes in Paris”
*/
[out:json][timeout:25];
// fetch area “Paris” to search in
{{geocodeArea:Paris}}->.searchArea;
// gather results
(
  // query part for: “amenity=atm”
  node["amenity"="atm"](area.searchArea);
  way["amenity"="atm"](area.searchArea);
  relation["amenity"="atm"](area.searchArea);
  // query part for: “atm=yes”
  node["atm"="yes"](area.searchArea);
  way["atm"="yes"](area.searchArea);
  relation["atm"="yes"](area.searchArea);
);
// print results
out body;
>;
out skel qt;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.