Skip to content
RGeo component for reading ESRI shapefiles
Find file
New pull request
Latest commit 67a9109 @teeparham teeparham Merge pull request #14 from das-g/let-open-return-block-value
let `` return the block's value


Gem Version Build Status

RGeo::Shapefile is an optional module for RGeo for reading geospatial data from ESRI shapefiles.


RGeo is a key component for writing location-aware applications in the Ruby programming language. At its core is an implementation of the industry standard OGC Simple Features Specification, which provides data representations of geometric objects such as points, lines, and polygons, along with a set of geometric analysis operations. See the README for the "rgeo" gem for more information.

RGeo::Shapefile is an optional RGeo add-on module for reading geospatial data from ESRI shapefiles. The shapefile format is a common file format for geospatial data sets. It is specified in this ESRI whitepaper.


require 'rgeo/shapefile''myshpfil.shp') do |file|
  puts "File contains #{file.num_records} records."
  file.each do |record|
    puts "Record number #{record.index}:"
    puts "  Geometry: #{record.geometry.as_text}"
    puts "  Attributes: #{record.attributes.inspect}"
  record =
  puts "First record geometry was: #{record.geometry.as_text}"


RGeo::Shapefile has the following requirements:

  • Ruby 1.9.3 or later preferred.
  • rgeo 0.3.13 or later.
  • dbf 1.7 or later.

Include in your bundle:

gem 'rgeo-shapefile'

Install RGeo::Shapefile as a gem:

gem install rgeo
gem install rgeo-shapefile

See the README for the "rgeo" gem, a required dependency, for further installation information.

If you are using Ruby 1.8, use version 0.2.x of this gem.

To-do list

  • Improve test case coverage.
  • Support for writing shapefiles.

Development and support

Documentation is available at

Source code is hosted on Github at

Contributions are welcome. Fork the project on Github.

Report bugs on Github issues at


RGeo is written by Daniel Azuma (

Development is supported by:

Although we don't use shapelib ( to read ESRI shapefiles, we did borrow a bunch of their test cases.


Copyright 2014 Daniel Azuma

Copyright 2014 Tee Parham

Something went wrong with that request. Please try again.