3

This refer to this post : Read Here

I'm in trouble when using osmosis command line to export data from planet-latest.osm.bz2 directly to osm2pgsql using some criteria to select what to transfer.

I think is more easy to export planet-latest.osm.bz2 to an XML with osmosis and then use osm2pgsql to import to Postgre, but I can't go further. So I need help in osmosis parameters to show how can I to export data using filters like

--place='city' --admin_level='2'

and import to Postgre using osm2pgsql.

Sorry about this very similar post, but the user was helping me was gived up.

Magno C
  • 2,140
  • 3
  • 24
  • 63

1 Answers1

1

Firstly, you can download OSM extracts that are already filtered by country/region/city directly from CloudMade: http://downloads.cloudmade.com/

Secondly, the reason your command isn't working is because osm2pgsql requires a filename to be passed in. On Linux you would use /dev/stdin (and this is what the osm2pgsql docs tell you to do) but it looks like you're on Windows. Try the standard filename - used by most linux-native programs (from the source code it looks like this should work):

osmosis --read-pbf-fast south-america.osm.bz2 --node-key-value keyValueList="place.city,admin_level.2" --write-xml output.xml | osm2pgsql -c -s -d OSMTest -U postgres -H 10.5.112.210 -P 5432 -S ./default.style -
dwurf
  • 324
  • 1
  • 4
  • 1
    cloudmade extracts are good if you don't care too much about data currency: http://gis.stackexchange.com/questions/29250/is-cloudmade-still-updating-osm-data-downloads – tomfumb Dec 11 '12 at 17:50
  • I don't want to work on filtered extracts. I need to work on planet-latest.osm.bz2 and select my own extracts. Anyway, the code in your example looks the same I show in the other post. Where can I put the stdin you show? Why this don't work in planet-latest.osm.bz2 ? I can work on Ubuntu with no problems, so you can tell me linux language. – Magno C Dec 12 '12 at 10:50
  • Well, trying the first part ( only osmosis export ) I received a Java heap OutOfMemory error. I need to solve this before reward you. If the osmosis export to XML works fine, the import to osm2pgsql will be easy. I don't care about making the process in two steps. – Magno C Dec 12 '12 at 11:11
  • 1
    Solved the out of memory error by setting JAVACMD_OPTIONS = -Xmx2048m -XX:MaxPermSize=256m -XX:PermSize=64M. Now I'm getting "Unable to get next blob from PBF stream" error. – Magno C Dec 12 '12 at 12:16
  • Solved "Unable to get next blob from PBF stream" error by changing --read-pbf-fast to --read-xml since south-america.osm.bz2 is not a binary file. It's a OSM XML file. – Magno C Dec 12 '12 at 12:25
  • 1
    Worked. the 2 steps process worked. After the export with osmosis --read-xml brazil.osm.bz2 --node-key-value keyValueList="place.city,admin_level.2" --write-xml output.osm I do osm2pgsql -c -s -d OSMTest -U postgres -W -H 10.5.112.210 -P 5432 ./output.osm -S ./default.style and the data was imported the way I need. Next I will try put all togeter in one step and try with planet-latest.osm.bz2. – Magno C Dec 12 '12 at 12:49
  • I'm glad you have it working! The only difference between the command in my answer and the one in your original comment is I have added a - at the end. Give that a try (should work on Windows or Linux) – dwurf Dec 12 '12 at 23:26