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

Hi, I'm using the windows version of osmfilter to try and extract city and town names with lat and long. The idea being to build a gazeteer for use in memory map. The command i use is

osmfilter spain.o5m --keep-tags="city" --keep-tags="town"-o=mycity.osm

The program runs, seems to be working but then keeps returning osmfilter error : write error

I've searched using google and one other person has asked about this error but no answer was given.

asked 05 Jan '14, 12:45

daveasbury's gravatar image

accept rate: 0%

edited 05 Jan '14, 13:29

Frederik%20Ramm's gravatar image

Frederik Ramm ♦

You have misunderstood the --keep-tags option. It does not actually filter the objects - it just decides which tags to copy over to the output. This means that your command will include all input objects in the output (instead of just cities and towns).

The write error is likely a consequence of this misunderstanding; your command results in a file of about 9 GB and it is possible that you are either out of disk space, or even using a file system that cannot handle files that large.

What you want is:

osmfilter spain.o5m --keep-nodes="place=city =town" --keep-ways= --keep-relations= -o=mycity.osm
permanent link

answered 05 Jan '14, 13:28

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

Thanks for the reply. I've sorted the write error. You are correct about the filtering. So is it possible to filter in the form - copy one town and cities?

I've tried various examples but none seem to do what i'm after

(05 Jan '14, 14:37) daveasbury

so you want to limit your result to a smaller area?

If yes, can you define that area via a boundingbox or a boundary relation from the OSM data? like ?

(06 Jan '14, 16:26) stephan75


What I am attempting is to take the file spain-latest.osm.pbf which i obtained, and extract all the towns and cities contained within it as well as their lat and long. This data would be ouput to a csv file in the form


Barcelona 28.00023 3.34568

benidorm 28.00034 3.90987

this I would hope to import into the program memory map navigator to create a town look up gazeteer.

(06 Jan '14, 19:52) daveasbury

The command in the grey box at the end of my original reply does just that (it doesn't give you a CSV but an OSM file with only towns and cities).

(07 Jan '14, 09:48) Frederik Ramm ♦

... and then use to convert your OSM file to a CSV file where you determine yourself what elements should be in the output file.

Read that documentation in the OSM wiki and try several tags.

(07 Jan '14, 16:51) stephan75

Thanks folks! finally sorted thanks to your replies using osmfilter spain.o5m --keep-nodes="place=city =town =village =hamlet =suburb =province" --keep-ways= --keep-relations= >mycity.osm


osmconvert mycity.osm --csv="name place province @lat @lon" -o=somefilename.csv

this i imported into memorymap to work with my Mobac maps and it works!

(07 Jan '14, 19:58) daveasbury
showing 5 of 6 show 1 more comments

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 05 Jan '14, 12:45

question was seen: 11,707 times

last updated: 08 Jan '14, 22:36

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