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:email@example.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:firstname.lastname@example.org/bikepathscph
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.
6 thoughts on “Sticking bicycle paths in CouchDB”
Great article, again!
Regarding encoding, check out the ESRI shapefile driver page:
You can specify the encoding of the .dbf file.
I had no problems on windows
Is it possible to use ogr2ogr options like – a_srs, -s_srs, -t_srs ?
If not, it would be nice to add the feature. Of course, the nice preview map wouldn’t work because it uses EPSG:4326 or EPSG:900913.
ogr2ogr.exe -f couchdb -nln cykelmidter “couchdb:http://rastermanden.iriscouch.com” Cykelmidter_2006_r2_ETRS89zone32N.shp
note: Requires (GDAL/OGR >= 1.9.0)
Hi, great to see our data in the wild. We’re currently working on updating and releasing more bicycle data, as well as looking into how best to work with OSM. Cheers, Emil Tin
Releasing data like this is a great for developers, as so is working with OSM. Keep up the good work!
Hi Kostas, use qgis to convert your SHP to UTF-8 encoding, set environment variable SHAPE_ENCODING=UTF-8 and use ogr2ogr -f couchdb… you’ll get your letters correctly into CouchDB.