Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Is there a way to select what to import from planet-latest.osm.bz2 to database?

I want to do something like :

osm2pgsql ...  --place='city' --admin_level='2'

My goal is to use only cities and countries im my project ( maybe towns ). I can download many databases with cities and countries shapes from the world, but I think OSM is more complete and if I decide to use other things is just import again.

I just try import all full planet data and then SELECT and INSERT in other database using SQL filters, but its too time-consuming ( and non-professional ).

Thanks.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You should use osmosis to filter OSM file to another OSM file and then osm2pgsql to import it. You can do it with single command using pipe as following

osmosis --read-pbf-fast planet-latest.osm.bz2 --node-key-value keyValueList="place.city,admin_level.2"  --write-xml - |osm2pgsql --append [my customized arguments] -
share|improve this answer
    
I got an "Usage Error" since ommited the filename from osm2pgsql ( I thing its correct ) : D:\osm2pgsql>osmosis --read-pbf-fast south-america.osm.bz2 --node-key-value keyValueList="place.city,admin_level.2" --write-xml - | osm2pgsql -c -s -d OSMTest -U postgres -H 10.5.112.210 -P 5432 -S ./default.style –  Magno C Nov 26 '12 at 14:59
    
@underdark : Thanks for correcting my text, teacher! –  Magno C Nov 26 '12 at 15:09
    
can you explain your answer to me? Still not work because I don't know how to mix you example with my arguments. Thanks. –  Magno C Nov 27 '12 at 18:50
    
The answer is here : link –  Magno C Dec 14 '12 at 14:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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