[gdal-dev] Convert Shape file to GeoJSON with gdal-ruby

igorti tihonovsson at gmail.com
Sun Apr 3 09:01:19 EDT 2011


I have compiled GDAL 1.8 with ruby bindings(ruby 1.8.7) on Ubuntu 10.10.

I'm trying to convert shape or tab files with code like this:

require 'gdal/ogr'
ds = Gdal::Ogr.open("point.shp")
drv = Gdal::Ogr.get_driver_by_name("GeoJSON")
drv.copy_data_source(ds, "point.json")

It works perfectly fine when I run this code from irb. 

Then I try to integrate this code with Ruby on Rails application.
Functionality is as follows - user uploads a zip with shape file. On the
serverside file is being unzipped and with the code above should be
converted to GeoJSON. Unzipped file is perfectly fine - I checked it with
QGIS 

The problem I'm running into is that when I'm converting shape file driver
creates an empty GeoJSON file. Though exact same file with exact same code
produces a valid GeoJSON when running from irb.

Any ideas why that's happening? Running same code in different processes
should not produce different results.

Any ideas highly appreciated! Thanks in advance!




--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Convert-Shape-file-to-GeoJSON-with-gdal-ruby-tp6234850p6234850.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list