| | 1 | = !OpenStreetMap = |
| | 2 | [[TOC]] |
| | 3 | |
| | 4 | '''Wikipedia of Maps''' |
| | 5 | |
| | 6 | == Base Map == |
| | 7 | We have out-of-the-box the ability to use !OpenStreetMap Tiles as base layer. |
| | 8 | |
| | 9 | This can include local OSM sites (OSM Taiwan is included as an example) |
| | 10 | |
| | 11 | == Vector Overlays == |
| | 12 | Can have OSM Vectors displayed over the top of other Base Layers (e.g. Satellite Images) |
| | 13 | |
| | 14 | * [wiki:BluePrintGISOSMLayers] |
| | 15 | |
| | 16 | == Import == |
| | 17 | We have an XSLT [http://eden.sahanafoundation.org/browser/static/formats/osm/import.xsl stylesheet] to import .osm files |
| | 18 | |
| | 19 | e.g for hospitals and clinics: |
| | 20 | {{{ |
| | 21 | osmosis --read-xml country.osm --tf accept-nodes amenity=hospital,clinic --tf reject-ways --tf reject-relations --write-xml nodes.osm |
| | 22 | osmosis --read-xml country.osm --tf reject-relations --tf accept-ways amenity=hospital,clinic --used-node --write-xml ways.osm |
| | 23 | osmosis --rx nodes.osm --rx ways.osm --merge --wx country_hospitals.osm |
| | 24 | http://myhost.com/eden/hms/hospital/create.osm?filename=country_hospitals.osm |
| | 25 | }}} |
| | 26 | |
| | 27 | This needs more work to understand the admin hierarchy properly to be able to import Places. |
| | 28 | * http://wiki.openstreetmap.org/wiki/Map_Features#Places |
| | 29 | * http://wiki.openstreetmap.org/wiki/Placename_hierachies is_in tag |
| | 30 | |
| | 31 | Geofabrik have updated extracts daily for Pakistan: |
| | 32 | * http://download.geofabrik.de/osm/asia/pakistan.osm.bz2 |
| | 33 | |
| | 34 | Otherwise pull a BBOX directly using Osmosis: |
| | 35 | * http://wiki.openstreetmap.org/wiki/Osmosis |
| | 36 | |
| | 37 | Osmosis requires Java. Python options for filtering based on tag, which would be more suitable for integration within Sahana, however we need to add Polygon filtering using Shapely: |
| | 38 | * http://dev.omniscale.net/imposm.parser/ |
| | 39 | * [http://pbf.raggedred.net ParsePBF] |
| | 40 | * http://blog.lifeeth.in/2011/02/extract-pois-from-osm-pbf.html |
| | 41 | |
| | 42 | Ruby script to generate KML of recently-added locations by a group of users: |
| | 43 | * http://github.com/vertis/osm_export/tree/master |
| | 44 | |
| | 45 | Polygons: |
| | 46 | * http://help.openstreetmap.org/questions/8273/how-do-i-extract-the-polygon-of-an-administrative-boundary |
| | 47 | |
| | 48 | == Basemap for Garmin GPS == |
| | 49 | * [wiki:UserGuidelinesGISDataOpenStreetMapGarmin] |
| | 50 | |
| | 51 | == Mirror == |
| | 52 | How to set up a local mirror for Africa with selected Feature types, suitable for use by Import PoI: |
| | 53 | {{{ |
| | 54 | apt-get install -y postgresql-8.4-postgis postgresql-contrib |
| | 55 | mkdir -p /home/osm/planet/replication |
| | 56 | cd /home/osm |
| | 57 | wget http://dev.openstreetmap.org/~bretth/osmosis-build/osmosis-latest.tgz |
| | 58 | tar zxvf osmosis-latest.tgz |
| | 59 | ln -sf /home/osm/osmosis-0.41 /home/osm/osmosis |
| | 60 | chown -R postgres /home/osm |
| | 61 | su postgres |
| | 62 | psql |
| | 63 | CREATE USER osm WITH PASSWORD 'planet'; |
| | 64 | \q |
| | 65 | createdb -O osm -E UTF8 osm -T template0 |
| | 66 | createlang plpgsql -d osm |
| | 67 | psql -d osm -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql |
| | 68 | psql -d osm -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql |
| | 69 | psql -d osm -f /usr/share/postgresql/8.4/contrib/hstore.sql |
| | 70 | psql -d osm -f /home/osm/osmosis/script/pgsnapshot_schema_0.6.sql |
| | 71 | psql |
| | 72 | \c osm |
| | 73 | ALTER TABLE geography_columns OWNER TO osm; |
| | 74 | ALTER TABLE geometry_columns OWNER TO osm; |
| | 75 | ALTER TABLE nodes OWNER TO osm; |
| | 76 | ALTER TABLE relation_members OWNER TO osm; |
| | 77 | ALTER TABLE relations OWNER TO osm; |
| | 78 | ALTER TABLE schema_info OWNER TO osm; |
| | 79 | ALTER TABLE spatial_ref_sys OWNER TO osm; |
| | 80 | ALTER TABLE users OWNER TO osm; |
| | 81 | ALTER TABLE way_nodes OWNER TO osm; |
| | 82 | ALTER TABLE ways OWNER TO osm; |
| | 83 | \q |
| | 84 | |
| | 85 | cd planet |
| | 86 | wget http://download.geofabrik.de/openstreetmap/africa.osm.bz2 |
| | 87 | bzcat /home/osm/planet/africa.osm.bz2 | /home/osm/osmosis/bin/osmosis --read-xml file=/dev/stdin --tf accept-nodes amenity=hospital,place_of_worship,school --tf accept-ways amenity=hospital,place_of_worship,school --write-pbf /home/osm/planet/eurosha.osm.pbf |
| | 88 | su postgres |
| | 89 | /home/osm/osmosis/bin/osmosis --read-pbf /home/osm/planet/eurosha.osm.pbf --write-pgsql database=osm user=osm password=planet |
| | 90 | |
| | 91 | cd /home/osm/planet/replication |
| | 92 | /home/osm/osmosis/bin/osmosis --rrii |
| | 93 | http://toolserver.org/~mazder/replicate-sequences/ |
| | 94 | ls -l /home/osm/planet/africa.osm.bz2 |
| | 95 | vi state.txt |
| | 96 | |
| | 97 | /home/osm/osmosis/bin/osmosis --rri workingDirectory=/home/osm/planet/replication/ --simc --read-pbf /home/osm/planet/eurosha.osm.pbf --ac --tf accept-nodes amenity=hospital,place_of_worship,school --tf accept-ways amenity=hospital,place_of_worship,school --tf reject-relations --write-pbf /home/osm/planet/eurosha-new.osm.pbf |
| | 98 | /home/osm/osmosis/bin/osmosis --read-pbf /home/osm/planet/eurosha-new.osm.pbf --read-pbf /home/osm/planet/eurosha.osm.pbf --dc --write-pgsql-change database=osm user=osm password=planet |
| | 99 | mv /home/osm/planet/eurosha-new.osm.pbf /home/osm/planet/eurosha.osm.pbf |
| | 100 | vim /home/osm/replicate.sh |
| | 101 | #!/bin/sh |
| | 102 | n=`ps -ef | grep -v grep | grep /home/osm/osmosis/ | wc -l` |
| | 103 | if [ $n -le 0 ] |
| | 104 | then |
| | 105 | if [ -s /home/osm/planet/eurosha-new.osm.pbf ] |
| | 106 | then |
| | 107 | mv /home/osm/planet/eurosha-new.osm.pbf /home/osm/planet/eurosha.osm.pbf |
| | 108 | fi |
| | 109 | /home/osm/osmosis/bin/osmosis --rri workingDirectory=/home/osm/planet/replication/ --simc --read-pbf /home/osm/planet/eurosha.osm.pbf --ac --tf accept-nodes amenity=hospital,place_of_worship,school --tf accept-ways amenity=hospital,place_of_worship,school --tf reject-relations --write-pbf /home/osm/planet/eurosha-new.osm.pbf |
| | 110 | /home/osm/osmosis/bin/osmosis --read-pbf /home/osm/planet/eurosha-new.osm.pbf --read-pbf /home/osm/planet/eurosha.osm.pbf --dc --write-pgsql-change database=osm user=osm password=planet |
| | 111 | fi |
| | 112 | |
| | 113 | chmod 0755 /home/osm/replicate.sh |
| | 114 | vim /etc/crontab |
| | 115 | 1 3 * * * root /home/osm/replicate.sh |
| | 116 | }}} |
| | 117 | |
| | 118 | Monitor: |
| | 119 | {{{ |
| | 120 | psql -d osm -c "select max(tstamp) from nodes"; |
| | 121 | }}} |