In this installment of How To Stick Anything In CouchDB, I’ll take some bicycle path data released by the municipality of Copenhagen and stick them in CouchDB. As always I’m working in Terminal under Mac OS X.
Bicycle paths in Copenhagen, served live by CouchDB:
Your browser does not support IFRAME
The data is in shape format, so it’s almost too easy using shp2geocouch. First download the data.
wget http://www.kk.dk/Borger/ByOgTrafik/CyklernesBy/~/media/B12983F7B5E3451F8716F7C072A5B101.ashx
mv B12983F7B5E3451F8716F7C072A5B101.ashx bikepaths.zip
unzip bikepaths.zip
What have we downloaded?
$ ls *.shp
Cykelmidter_2006_r2_ETRS89zone32N.shp Cykelmidter_2006_r2_WGS84.shp
Create a CouchDB database to hold the data. I’m using my CouchDB installation. You should use yours:
curl -X PUT username:password@gd.iriscouch.com/bikepathscph
Use shp2geocouch to upload the data. It shouldn’t matter which one of the shape files we use, because shp2geocouch does reprojection:
shp2geocouch Cykelmidter_2006_r2_WGS84.shp http://username:password@gd.iriscouch.com/bikepathscph
Notes
There is a problem with encoding. If you click on one of the street features on the map above, streets that contain the danish letters [æ,ø,å] are missing those letters. I tried testing a conversion to GeoJSON from the shapefiles with ogr2ogr and it’s the same. God I hate encoding!
By the way, this is how to convert to GeoJSON from Shape using ogr2ogr:
ogr2ogr -f "GeoJSON" cykelmidter.json Cykelmidter_2006_r2_WGS84.shp
If you don’t have shp2geocouch, it’s really easy to install (at least it was on my Mac):
sudo gem install shp2geocouch
There is a “Ruby gem” install home page here, and github here.
Leave a Reply
You must be logged in to post a comment.