Playing with Osmosis

Command to filter the file with tag amenity=school and write the filtered data in second file.

$ osmosis –read-xml file=”ludhiana.osm” –nkv keyValueList=”amenity.school” –write-xml file=”school.osm”

Do you want to update your OSM data without deleting existing data?

So here are the steps given below.

Step 1

Derive a change set between two files. The first file is the file after changing, the second planet file is the file before changing. The changeset will be written in the third file.

$ osmosis –read-xml file=”classroom.osm” –read-xml file=”class_lib_tcc.osm” –derive-change –write-xml-change file=”classroom_classlibtcc_diff.osm”

Step 2

Dump the changeset to the database in append mode. It means it will change only affected data. Rest will exist there.

$ osm2pgsql –slim -a -d classroom -C 2500 –hstore -S openstreetmap-carto.style ~/osmosis_files/class_audi_diff.osm

And you are done.:)

Note: Osmosis and osm2pgsql have different schemas. So for using postgis flags of osmosis we have to create schema compatible with osmosis. I followed this link to create ans setup database.

For my satisfaction, I have written that command again.

$ psql -d classroom -f /home/amisha/osm/osmosis/script/pgsnapshot_schema_0.6_action.sql

OUTPUT

CREATE TABLE
ALTER TABLE

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s