GithubHelp home page GithubHelp logo

map-gather's Introduction

#map-gather

Version 0.0.1

A command-line ruby script to scrape the tablular data of an ArcGIS Server feature layer through the REST API and store the results locally in a CSV.

###Methodology

There is no easy way for a user to get all of the tabular data for a large (> 1,000 features) ArcGIS Server feature layer. ArcGIS Server does not provide "bulk download" functionality, nor does the REST API allow you to query for more than 1,000 features at a time (at least under the default server configuration). However, by default, there is no limit on the number of results for a query that returns only the ObjectIDs for all of the features in a layer. Therefore, to scrape the tabular data of a feature layer, map-gather first queries for the ObjectIDs of all of the features in the provided layer. Then, in batches of 100, WHERE OBJECTD ID IN (1, 2, 3,...) queries are made (~2 seconds apart, as to not overwhelm the server) until all of the features are retrieved. The results are written locally to a CSV file.

###Dependencies

  • Ruby
  • rest-client
  • An open (i.e. no auth token/password needed) ArcGIS Server REST API endpoint to query

###Usage

$ ruby map_gather.rb REST_API_URL OUTPUT_FILE_NAME

Or, more specifically:

$ ruby map_gather.rb http://www.example.com/ArcGIS/rest/services/folder_name/map_name/MapServer/layer_index/query output.csv

Example:

$ ruby map_gather.rb http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/6/query output.csv
Getting list of OBJECTIDs...
Success!
Creating output file...
Getting and saving features...
...at OID 100, 25.44529262086514% Done
...at OID 200, 50.89058524173028% Done
...at OID 300, 76.33587786259542% Done
Done!

Output:

output sample

###TODO

  • Better error handling/checking
  • Add optional arguments to modify query parameters
  • Add optional arguments to adjust throttle time
  • Create tests

map-gather's People

Contributors

mdb avatar

Watchers

James Cloos 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.