Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

this is repost of the same question on Stackoverflow where I got no answers so far

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
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

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!

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: – 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).

share|improve this answer

Your Answer


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.