Giter VIP home page Giter VIP logo

geoservices-ruby's Introduction

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

Install

Just install using Rubygems:

gem install geoservices

Usage

@service = Geoservice::MapService.new(:url => "http://rmgsc.cr.usgs.gov/ArcGIS/rest/services/nhss_weat/MapServer")
@service.layers[0]["name"] #=> "Watches/Warnings"

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

Query

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 = "https://services2.arcgis.com/1gVyYKfYgW5Nxb1V/ArcGIS/rest/services/MesaAzCouncilDistricts/FeatureServer"
service = Geoservice::MapService.new(url: 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"}}

Testing

geoservices-ruby uses RSpec for tests.

$ rake rspec

Requirements

  • Ruby

Resources

Licensing

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

http://www.apache.org/licenses/LICENSE-2.0

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)

geoservices-ruby's People

Contributors

ajturner avatar

Watchers

James Cloos avatar karlitxo avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.