NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I want to use osmconvert to .csv to put certain fields into a csv file and I want to keep the relations.

First, I want to run osmfilter to filter data to just street, city, state, lat, long where street, city, and state are all populated for each record. In other words, I don't want a bunch of records with the state populated but not the city and street.

I created a parameters file with the following -v

-keep= -keep-relations all addr:street!= addr:city!= addr:state!=

Then I run osmconvert like below, but I am getting records where the state is just populated. Also, I see records where the just street and city are populated. ./osmconvert planetfile.osm --csv"addr:street addr:city addr:state" --csv-headline -o=filteredfile.csv.

I also tried @lat and @long in the above statement to filter lat and long for the street as well, but then it didn't report any streets, cities or states, just lat and long.

So, I guess there is two questions? How do I filter the data such that all the fields I need are populated? And how do I tack on lat and long in the convert statement to get it to appear with the addresses in the csv?

asked 14 Sep '12, 17:06

JMB5's gravatar image

JMB5
16334
accept rate: 0%

many many thanxk you helped me alot

(22 May '14, 21:53) say_hello_to...

Jochen is right, Osmium is much more fexible if you want to do special data processing. However, what you want to accomplish can be done with osmfilter/osmconvert too. For example:

$ ./osmfilter bremen.o5m --keep="addr:country= and addr:city= and addr:street=" --ignore-dependencies | ./osmconvert - --csv="@oname @id @lon @lat addr:country addr:city addr:street"

node 103065646 8.7174590 53.1528516 DE Bremen Alwin-Lonke-Straße
node 103075917 8.7113611 53.1501230 DE Bremen Grambker Heerstraße
node 169500351 8.8907070 53.0349470 DE Bremen Europaallee
node 171358853 8.8809487 53.0704234 DE Bremen Hützelstrasse
node 172133861 8.8860047 53.0607349 DE Bremen Hemelinger Bahnhofstraße
node 175673452 8.9541837 53.0338771 DE Achim Uphuser Heerstraße
node 175675316 8.9675299 53.0574772 DE Oyten Oyterdamm
...

I am just not sure what you mean with "keeping the relations". If you really want only relations but nothing else, you might want to filter this way:

$ ./osmfilter bremen.o5m --keep="" --keep-relations="addr:country= and ...

permanent link

answered 18 Sep '12, 23:52

Marqqs's gravatar image

Marqqs
448510
accept rate: 22%

overwhelming - you saved my day: many many thanks for sharing your insights - great!

(22 May '14, 20:26) say_hello_to...

hi there! could you help out? I am using your osmfilter nodes_hiAgra.osm --keep="addr:street=" --ignore-depemdencies --drop-relations --drop-ways |osmconvert - --csv="@id @lon @lat addr:street " and only got 1 line .... But streets are more in that area What to do? I need only id,lon,lat, street_name

(11 Jun '14, 12:44) Gevork

I am not sure I understand exactly what you want, but if you find that osmconvert doesn't do what you need, you might want to try Osmium, specifically the "osmjs" utility that comes with it. Osmjs can also create CSV files and you can write small Javascript snippets to define exactly what you need, so it is rather flexible. There are examples in the "osmjs" directory in the distribution.

permanent link

answered 16 Sep '12, 07:56

Jochen%20Topf's gravatar image

Jochen Topf
5.2k55074
accept rate: 31%

hello dear jochen many many thanks for sharing your insights - great! you helped me alot

(22 May '14, 20:25) say_hello_to...

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×60
×47
×42

question asked: 14 Sep '12, 17:06

question was seen: 9,375 times

last updated: 11 Jun '14, 12:44

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum