Ruby library for interacting with Geoservices
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

GeoServices Ruby Library

This library is a simple wrapper around the GeoServices API. You can see the GeoServices REST Specification or the Getting Started

If you have not worked with GeoServices before, there are a few basic concepts to get started:

  • Service is the base and has many layers. This just holds metadata about who created the service, and the layers it contains.
  • Layer a layer is like a dataset with many features. You can query a Layer by spatial extent, attribute parameters and even perform aggregations with statistics and group by fields
  • Feature an individual location, or record, or row, is called a 'feature'. A feature has many attributes


Just install using Rubygems:

gem install geoservices


@service = => "")
@service.layers[0]["name"] #=> "Watches/Warnings"

If calling to a secure service, include :token => TOKEN in the constructor.


To request data from a service, you need the URL to the service, the layer index, and then add optional query parameters.

To get all features:

service_url = ""
service = service_url)
features = service.query(0)["features"]
puts features.length #=> 6
puts features.first["attributes"]
#=> {"OBJECTID"=>1, "DISTRICT"=>1, "DISTRICTS"=>"DISTRICT 1", "FACILITYID"=>nil, "GLOBALID"=>"1c14efc5-cef2-4757-a9f5-8be2c3eeab66"}

You can also perform spatial queries:

params = {
  geometry: [-111.835,33.42].join(','),
  geometryType: "esriGeometryPoint",
  inSR: 4326,
  spatialRel: "esriSpatialRelIntersects",
  units: "esriSRUnit_Meter",
  returnGeometry: false
query = service.query(0, params)
puts query["features"]
#=> {"attributes"=>{"OBJECTID"=>4, "DISTRICT"=>4, "DISTRICTS"=>"DISTRICT 4", "FACILITYID"=>nil, "GLOBALID"=>"c9f2f6f1-d210-4332-8610-8ad176ab9d07"}}


geoservices-ruby uses RSpec for tests.

$ rake rspec


  • Ruby



Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's license.txt file.

[](Esri Tags: ArcGIS Ruby API GeoServices Public) [](Esri Language: Ruby)