Sunday, March 20, 2011

How-To: Spatial and Ruby on OSX

Notes on getting started using Ruby and rgeo on OSX to manipulate spatial data. 


Setup:
1. Download and install ruby 1.92
$ curl ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p180.tar.gz -o ruby-1.9.2-p180.tar.gz 
$ tar xvfz ruby-1.9.2-p180.tar.gz
$ cd ruby-1.9.2-p180
$ ./configure
$ make
$ sudo make install
2. Download and install homebrew package manager
$ ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
3. Download and install geos and proj libraries. The ruby gem rgeo requires geos and proj. While it is possible to build rgeo against  the Kyng Chaos Frameworks, it's far easier to install these libraries using brew.
$ brew install geos
$ brew intall proj
4. Install rgeo. RGeo is a ruby gem based on the OGC Simple Features Specification.
$ sudo gem install rgeo
5. Install supporting rgeo gems.
Shapefile:
$ sudo gem install dbf
$ sudo gem install rgeo-shapefile
PostGIS:
$ gem install pg
$ gem install rgeo-activerecord
$ gem install activerecord-postgis-adapter
GeoJSON:
$ gem install rgeo-geojson

No comments:

Post a Comment