Friday 14 June 2019

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


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.




Answer



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 planet-latest.osm.bz2 --node-key-value keyValueList="place.city,admin_level.2"  --write-xml - |osm2pgsql --append [my customized arguments] -

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...