When I was deployed with Nicolas in Haiti after the 2010 quake I wrote a quick 
and dirty python script to automate conversion from JOSM XML preset files into 
something usable by osm2pgsql. It's called 'preset2style.py' and lives at 
https://github.com/hotosm/scripts.

I never imagined it would still be in use, but it is. COSMHA [1] workflows in 
Haiti still actively use it. So, just thought I would send out a quick 
background to the list on this script in case anyone might benefit from it or 
have ideas to improve it.

Basically, as you all know, the humanitarian data model [1] uses custom tags 
which are often very long. A frequent task for visualizing osm data with custom 
tags is to import it into PostGIS (postgres database) so that the data can be 
easily viewed in QuantumGIS and filtered, since shapefiles will truncate long 
column names.

Osm2pgsql is not the easiest tool to use for beginners but is robust (it is 
used to import data for rendering at tile.osm.org) and has a windows binary 
thanks to Jon Burgess (that I was able to package into an easy installer [3] 
for haiti deploys). The problem however is that, by default, osm2pgsql only 
supports a limited set of tags to import into postgis and needs to be extended 
to notice the HOT tags. Because JOSM preset files are in active use by HOT to 
guide data collection, it makes sense to automatically pull the tags out of a 
given preset file, merge these with the default set of osm2pgsql tags, and 
generate a new style to get the right tags for import. That is basically what 
this simple script does, not much more.

As I mentioned above, this was a very quick and dirty solution. Lots of ways to 
improve it. I'm personally following the osmium project  [4] because I think 
that looks like a great library for flexible osm data conversion. But until we 
can replace the JOSM->preset2style.py->osm2pgsql workflow with something better 
(that works on windows), I just wanted to get these details out there :)

Cheers,

Dane


[1] http://hot.openstreetmap.org/weblog/2011/01/13/
[2] http://wiki.openstreetmap.org/wiki/Humanitarian_OSM_Tags
[3] https://github.com/hotosm/installer
[4] https://github.com/joto/osmium
_______________________________________________
HOT mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/hot

Reply via email to