Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

this is repost of the same question on Stackoverflow where I got no answers so far http://stackoverflow.com/questions/5687130/how-to-write-into-dbase-tables-using-ruby-on-osx

So, from OSX(Lion) using Ruby(1.9.x), I am trying to update data from an ESRI Shapefile. I didn't find any gem with dbf write support or at least some ODBC driver that I can use on OSX.

share|improve this question
1  
Just a warning - you can EDIT the existing data with a DBF editor, but you cannot add, remove, or move any rows. If you do so, your Shapes will not correspond with their correct Attribute rows as they use indexing and not an ID for the relationship. –  Sasa Ivetic Sep 1 '11 at 13:52
    
Yap, this I want to do, only update fields. On windows, I am using ODBC and works like a charm, not the same on OSX :( –  Vasile Cotovanu Sep 2 '11 at 23:16

2 Answers 2

You can write shapefiles (including the .dbf file) with Georuby (OSX supported)

"GeoRuby provides data types intended to hold data returned from PostGIS and the Spatial Extensions of MySql. The data model roughly follows the OGC Simple Features for SQL specification, although without any kind of advanced functionalities (such as geometric operators or reprojections). The library inputs and outputs EWKB, HexEWKB and EWKT. A recent version also includes input and output of GeoRSS and KML. The latest versions have added support for reading and writing ESRI shapefile"

To keep this in the GISse domain: Advisory for Shapefiles - you should write shapefile (.shp, .dbf and .shx at the same time) editing .dbf on their own can cause issues if not very careful!

http://georuby.rubyforge.org/

share|improve this answer
    
Thanks for your answer. The "problem" with GeoRuby is that is old, last update is March 20, 2009 and can't reproject the data. I wish that RGeo (Daniel Azuma's) to bring write support soon. –  Vasile Cotovanu Sep 1 '11 at 14:05
    
I ended up using Python with GDAL bindings. For anyone interested, here is a snippet: pastie.org/2758295 –  Vasile Cotovanu Oct 25 '11 at 20:26

I have never used ruby myself, but I know there are ruby bindings to shapelib. This has good dbf support (among others used by R). http://shapelib.maptools.org/ http://sourceforge.net/projects/ruby-shapelib

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.