{ "info": { "author": "Ken Schwencke", "author_email": "schwank@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "[![PyPI version](https://badge.fury.io/py/arcgis-rest-query.svg)](http://badge.fury.io/py/arcgis-rest-query) ![travis-ci status](https://travis-ci.org/Schwanksta/python-arcgis-rest-query.svg?branch=master)\n# ArcGIS REST Query\n\nA simple library that can download a layer from a map in an \nArcGIS web service and convert it to something useful: GeoJSON.\n\n## Usage\n\n```python\n>>> import arcgis\n>>> source = \"http://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Congressional_Districts/FeatureServer\"\n>>> service = arcgis.ArcGIS(source)\n>>> layer_id = 0\n>>> shapes = service.get(layer_id, \"STATE_ABBR='IN'\")\n```\n\nThis assumes you've inspected your ArcGIS services endpoint to know what to look for.\nArcGIS DOES publish json files enumerating the endpoints you can query, so autodiscovery\ncould be possible further down the line.\n\n## Installation\n\nThe easiest way:\n```bash\npip install arcgis-rest-query\n```\nFrom source:\n\n```bash\n# Create a virtual environment (pip install virtualenv if you don't have it already)\nvirtualenv python-arcgis-rest-query\ncd python-arcgis-rest-query\n. bin/activate\ngit clone git@github.com:Schwanksta/python-arcgis-rest-query repo\ncd repo\npip install -r requirements.txt\n```\n\n## From the command line\n\nYou can also use the included arcgis-get utility, like so:\n\n```bash\n$ arcgis-get http://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/Legislative/MapServer 0 --where=\"STATE = 15\" > hawaii_congressional_districts.geojson\n```\nThis will download the 114th Congressional District shapes for Hawaii (FIPS ID is 15). We filter down in this example because there are a bunch of congressional districts, and it would take a while to download them all.\n\nYou should run `--count_only` before downloading an entire dataset, so you can see what you're in store for.\n\n```bash\n$ arcgis-get http://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/Legislative/MapServer 0 --count_only\n444\n```\nThe utilitiy downloads in batches of 1000, so while this will only need to hit the API once, the resulting file would be rather large.\n\nYou can also download multiple layers into the same file from the command line. For example, if you wanted to combine the Tennessee congressional districts for the 114th and 113th congress into the same file:\n\n```bash\n$ arcgis-get http://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/Legislative/MapServer 0 12 --where=\"STATE = 47\" --layer_name_field='source_layer' > tn_distrcits_2013_2014.geojson\n```\n\n# API\n## Constructor\nThe ArcGIS() constructor takes only one required argument, the URL to the web services endpoint you wish to query.\n```python\n>>> from arcgis import ArcGIS\n>>> service = ArcGIS(\"http://tigerweb.geo.census.gov/arcgis/rest/services/Basemaps/CommunityTIGER/MapServer\")\n```\n\n### Authenticating requests to your ArcGIS server\nIf your ArcGIS endpoint is protected via token authorization, pass a valid username/password to the constructor\nto validate your requests via token auth:\n\n```python\n>>> import os\n>>> from arcgis import ArcGIS\n>>> username = os.getenv('ARCGIS_USERNAME', None)\n>>> password = os.getenv('ARCGIS_PASSWORD', None)\n>>> service = ArcGIS(\"http://hostname/to/token/auth/featureServer\",\n username=username,\n password=password)\n```\nYou can then continue making requests as detailed below.\n\n## ArcGIS.get(layer[,where=\"1 = 1\", fields=[], count_only=False, srid='4326'])\n\nGets a single layer from the web service.\n\n```python\n>>> geojson = service.get(28)\n>>> only_florida = service.get(28, where=\"NAME = 'Florida'\")\n>>> # Specifying the fields means we get only those fields in return\n>>> only_florida_shape = service.get(28, where=\"NAME = 'Florida'\", fields=['OBJECTID'])\n```\n\nIf `count_only` is specified, we return a simple count of the number of features in the layer you're querying. This is useful for determining how big of a query you're about to make, or if your `WHERE` filter is correct.\n\n```python\n>>> states_count = service.get(28, count_only=True)\n56\n>>> southeast_count = service.get(28, where=\"NAME IN ('Florida', 'Georgia', 'Alabama', 'South Carolina')\", count_only=True)\n4\n```\n\n### ArcGIS.getMultiple(layers[, where=\"1 = 1\", fields=[], srid='4326', layer_name_field=None])\n\nConcatenate multiple layers into one geojson. This is useful if you have a map with layers for, say, every year, named foo_2014, foo_2013, foo_2012, etc. Setting `layer_name_field` adds a field to every returned object specifying which layer it came from.\n\n```python\n>>> service = ArcGIS(\"http://tigerweb.geo.census.gov/arcgis/rest/services/Census2010/Transportation/MapServer\")\n>>> # Get any primary or secondary roads named after MLK Jr. and combine them.\n>>> mlk_roads = service.getMultiple([0,1], where=\"NAME LIKE '%Martin Luther King%'\", layer_name_field=\"src_layer\")\n>>> # Inspect the src_layer field in the first returned feature.\n>>> mlk_roads.get('features')[0].get('properties').get('src_layer')\nu'Primary Roads'\n```\n\n### ArcGIS.get_json(layer[, where=\"1 = 1\", fields=[], count_only=False, srid='4326'])\n\nReturns the raw JSON from ArcGIS web services for the layer. This is not GeoJSON.\n\n```python\n>>> raw_json = service.get_json(0)\n```\n\n### ArcGIS.get_descriptor_for_layer(layer)\n\nReturns the JSON descriptor for the layer. This tells you things like what fields are in the layer, what sort of geometry it contains, etc. The response of this function is cached, so repeated calls to the same layer will not hit the ArcGIS web service.\n\n```python\n>>> descriptor = service.get_descriptor(0)\n```\n\n### ArcGIS.enumerate_layer_fields(layer)\n\nReturns a list of the field names in the layer. Useful for determining what you want to request in a `.get()` call.\n\n```python\n>>> field_list = service.enumerate_layer_fields(0)\n```\n\n# Piping to geojsonio\n\nIf you install [geojsonio-cli](https://github.com/mapbox/geojsonio-cli/), you can pipe output directly to a viewable map.\n\n```bash\nnpm install -g geojsonio-cli\n```\n\nThen, we could re-do the query on Hawaii's congressional districts:\n\n```bash\n$ arcgis-get http://tigerweb.geo.census.gov/arcgis/rest/services/TIGERweb/Legislative/MapServer 0 --where=\"STATE = 15\" | geojsonio\n```\n\nAnd get some glorious mapped output:\n![hawaii](https://cloud.githubusercontent.com/assets/20067/5095404/85de3610-6f37-11e4-8658-d769a89590a9.png)\n\nOr, for example, if you want to get the Census' state shape for just Florida and display it on geojson.io, you could do:\n\n```bash\narcgis-get --where=\"NAME = 'Florida'\" http://tigerweb.geo.census.gov/arcgis/rest/services/Basemaps/CommunityTIGER/MapServer 28 | geojsonio\n```\n\n![florida](https://cloud.githubusercontent.com/assets/20067/5001808/ee233ff6-69c7-11e4-9c3e-245aba847bb5.png)\n\n# Potential pitfalls\n\nSince you can only query in batches of 1,000, and sometimes these are millions of records, these operations could take a long time. Currently there's no status indicator on the CLI, so run `--count_only` first to see how long you might wait.\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Schwanksta/python-arcgis-rest-query", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "arcgis-rest-query", "package_url": "https://pypi.org/project/arcgis-rest-query/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/arcgis-rest-query/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/Schwanksta/python-arcgis-rest-query" }, "release_url": "https://pypi.org/project/arcgis-rest-query/0.14/", "requires_dist": null, "requires_python": null, "summary": "A tool to download a layer from an ArcGIS web service as GeoJSON", "version": "0.14" }, "last_serial": 1951767, "releases": { "0.0.10": [ { "comment_text": "", "digests": { "md5": "fd34fbb2b8bbcf5dc3acae3d50114771", "sha256": "39f9f1356e8099e1b6cfba7387bf4a41151f8cecb8e2fa58f7ce6fdfccc52cec" }, "downloads": -1, "filename": "arcgis-rest-query-0.0.10.tar.gz", "has_sig": false, "md5_digest": "fd34fbb2b8bbcf5dc3acae3d50114771", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6574, "upload_time": "2015-03-24T21:32:22", "url": "https://files.pythonhosted.org/packages/7f/72/0e921af7dca7966ae3f07d7db8b51346b6e5ab44298351ed1a0fe863564f/arcgis-rest-query-0.0.10.tar.gz" } ], "0.0.11": [ { "comment_text": "", "digests": { "md5": "d3d1d8ec551414ba0db57d515168578a", "sha256": "615c5d099fcc5c1e37391757ff8f6dd6e7616f2cf0356f966d9b1477a2b27b9f" }, "downloads": -1, "filename": "arcgis-rest-query-0.0.11.tar.gz", "has_sig": false, "md5_digest": "d3d1d8ec551414ba0db57d515168578a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6574, "upload_time": "2015-03-24T21:46:39", "url": "https://files.pythonhosted.org/packages/31/c6/63da4b7f0858c7715299d853c4f48a7d61cb342cd50510c4fae6cd48a17e/arcgis-rest-query-0.0.11.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "9b8b01893d44fcfb55773ad8d3ce4e3f", "sha256": "c91ae138c6afbc3c6ef9e5fc7912812fab5dc5abc9fafc943a69f6394573f885" }, "downloads": -1, "filename": "arcgis-rest-query-0.0.2.tar.gz", "has_sig": false, "md5_digest": "9b8b01893d44fcfb55773ad8d3ce4e3f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4632, "upload_time": "2014-11-12T17:12:26", "url": "https://files.pythonhosted.org/packages/42/17/105d5fca78e310a49cf410d9632c4b0f19361d3b9d7133f5668901e59878/arcgis-rest-query-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "4e6b017b9961235b7fa42ea81d664340", "sha256": "acb097e37194449fde25607ad6c98a98d7418b91aaa7e53ea15a335802ebbf57" }, "downloads": -1, "filename": "arcgis-rest-query-0.0.3.tar.gz", "has_sig": false, "md5_digest": "4e6b017b9961235b7fa42ea81d664340", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4784, "upload_time": "2014-11-12T17:23:00", "url": "https://files.pythonhosted.org/packages/25/b4/25bc604331b56ffc5cbbb8fd5fac29ee363738e87ddbe242f05a5f266c02/arcgis-rest-query-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "2add04255dc8fd291b3959bacdd3aedd", "sha256": "eddc112302df9358792e4e878134c2c36be08148d0d950a78d7a99ae8be53207" }, "downloads": -1, "filename": "arcgis-rest-query-0.0.4.tar.gz", "has_sig": false, "md5_digest": "2add04255dc8fd291b3959bacdd3aedd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5104, "upload_time": "2014-11-13T02:38:51", "url": "https://files.pythonhosted.org/packages/13/10/8277f467a13f7b81a8825af71f71f674233dfebdb88f64308e0fb2fe656e/arcgis-rest-query-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "2ac30b34eae8a005f65f61b990750fc5", "sha256": "f63dd2d65ac8bf8d6eda4aef569644df0073c57c550d4839f7a40ac5f5877539" }, "downloads": -1, "filename": "arcgis-rest-query-0.0.5.tar.gz", "has_sig": false, "md5_digest": "2ac30b34eae8a005f65f61b990750fc5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5089, "upload_time": "2014-11-13T02:41:37", "url": "https://files.pythonhosted.org/packages/7f/82/a06fe74c17dd10a3211f789169237f4f888c1092137c8130ef01f627d5b3/arcgis-rest-query-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "77b3c4359b780362c48e956aa15bb2b1", "sha256": "74de81e154386d8d067d5f1ec8b8205897003c38e64d5166f87b17246dc7e05e" }, "downloads": -1, "filename": "arcgis-rest-query-0.0.6.tar.gz", "has_sig": false, "md5_digest": "77b3c4359b780362c48e956aa15bb2b1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5089, "upload_time": "2014-11-14T19:40:08", "url": "https://files.pythonhosted.org/packages/53/e6/865f3e8932d5fb5890cc337c357662716d6c51b8aa3ea23997f8fa0b5765/arcgis-rest-query-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "54df0ebea49210e33b6fb95bc66561a6", "sha256": "fda008684a0aeeb06a80608809452124952faa8a8e0e852072d73082f5f4cbd2" }, "downloads": -1, "filename": "arcgis-rest-query-0.0.7.tar.gz", "has_sig": false, "md5_digest": "54df0ebea49210e33b6fb95bc66561a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5558, "upload_time": "2014-11-18T03:14:57", "url": "https://files.pythonhosted.org/packages/c0/63/07df522cfd752af41073dc8f3a2b2c04c8a89f171dfaa893e9877dfe8190/arcgis-rest-query-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "eac77696d52e655bc2b5ab20e09f145c", "sha256": "5e9041b34d56dc36b9ab4ad6f11506677cd930fc07bc34a1580292698f0e7745" }, "downloads": -1, "filename": "arcgis-rest-query-0.0.8.tar.gz", "has_sig": false, "md5_digest": "eac77696d52e655bc2b5ab20e09f145c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6565, "upload_time": "2014-11-18T21:01:37", "url": "https://files.pythonhosted.org/packages/8c/cf/1ab1650b0813f5cfad041a6bd5e33761c47b551006e09d10ac58ba1ef059/arcgis-rest-query-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "fe135eb03e5dcf6c9914938f92234519", "sha256": "4cdab4b494d00cc221fe0f707006575cffd3a8b30f7a3c9f9bb9ade5f25cb432" }, "downloads": -1, "filename": "arcgis-rest-query-0.0.9.tar.gz", "has_sig": false, "md5_digest": "fe135eb03e5dcf6c9914938f92234519", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6562, "upload_time": "2014-11-20T20:40:35", "url": "https://files.pythonhosted.org/packages/e2/1a/ec4e56148f94578bc5f8f6f2b2849da0a37240cafeac6a00557d518fb354/arcgis-rest-query-0.0.9.tar.gz" } ], "0.1": [ { "comment_text": "", "digests": { "md5": "f9c78cf0fb568318a7e2dcfeac1d2aeb", "sha256": "8adfec01f70afdb6ebf1456a5c7cab2b1da7909d5a169310d1ca932f26f0730d" }, "downloads": -1, "filename": "arcgis-rest-query-0.1.tar.gz", "has_sig": false, "md5_digest": "f9c78cf0fb568318a7e2dcfeac1d2aeb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6870, "upload_time": "2015-09-18T20:37:48", "url": "https://files.pythonhosted.org/packages/02/12/f77c56063352da46fcd4b1c2e84cd32cca100b9fa83621daae05fa2a844b/arcgis-rest-query-0.1.tar.gz" } ], "0.11": [ { "comment_text": "", "digests": { "md5": "ffd1cfc19e0cfd40f0a7989161ff27c0", "sha256": "d77fa1a31361634ce103090718852a1eaa1d61100889dcfe85e94f6ae496a96d" }, "downloads": -1, "filename": "arcgis-rest-query-0.11.tar.gz", "has_sig": false, "md5_digest": "ffd1cfc19e0cfd40f0a7989161ff27c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7449, "upload_time": "2015-11-06T19:23:47", "url": "https://files.pythonhosted.org/packages/09/d0/4b76ed00c8e54e8fc6d378da087c7f6114d384e2c82e663cfe4940110caa/arcgis-rest-query-0.11.tar.gz" } ], "0.12": [ { "comment_text": "", "digests": { "md5": "7c1b36f3bba34e9386a1709e7408319a", "sha256": "22c0e9c19eaf3ceff40a2a6d8a4045f3bc1b02b5c1d6f1ae1af222e0e0a8ea7e" }, "downloads": -1, "filename": "arcgis-rest-query-0.12.tar.gz", "has_sig": false, "md5_digest": "7c1b36f3bba34e9386a1709e7408319a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7512, "upload_time": "2016-01-28T23:03:22", "url": "https://files.pythonhosted.org/packages/bc/53/8531e120f4c4317c394677372d01c33269c544612d391dc40f98256b248d/arcgis-rest-query-0.12.tar.gz" } ], "0.13": [ { "comment_text": "", "digests": { "md5": "fe6e2085887bc79b28f13c305bd9c747", "sha256": "5364dd8f755da88a2ed5bb3a0f02e8943bf4c94c30074cc5bc081cee27f1d4bc" }, "downloads": -1, "filename": "arcgis-rest-query-0.13.tar.gz", "has_sig": false, "md5_digest": "fe6e2085887bc79b28f13c305bd9c747", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7592, "upload_time": "2016-01-29T21:02:18", "url": "https://files.pythonhosted.org/packages/01/8b/6ec4899c86ababe3d8e13a7832f66a3a87a32673741be92ee6116ad2bbec/arcgis-rest-query-0.13.tar.gz" } ], "0.14": [ { "comment_text": "", "digests": { "md5": "b3adbac131bdcc4bd4535e147a83971f", "sha256": "796f16172a7bbf67199790b86930844e4382fe59e68446e9505eabbddbfdcc97" }, "downloads": -1, "filename": "arcgis-rest-query-0.14.tar.gz", "has_sig": false, "md5_digest": "b3adbac131bdcc4bd4535e147a83971f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7606, "upload_time": "2016-02-11T19:54:26", "url": "https://files.pythonhosted.org/packages/43/3b/4bbc1e772e00257f14387b7982b20abee35a56690c7c5b8f12c6cfa9408d/arcgis-rest-query-0.14.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "87e9e2a037e89d7dfe975dafc2e0bea9", "sha256": "0c6dcf4bd819f4f5e11e22c01d05a5f501e70ab39965410b67f17dc21e6b4eb4" }, "downloads": -1, "filename": "arcgis-rest-query-0.2.tar.gz", "has_sig": false, "md5_digest": "87e9e2a037e89d7dfe975dafc2e0bea9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7508, "upload_time": "2016-01-28T22:59:22", "url": "https://files.pythonhosted.org/packages/f3/89/6df402eba21953fce8c18f1f66982022d9e0cd399bd56b97218c14866a6e/arcgis-rest-query-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b3adbac131bdcc4bd4535e147a83971f", "sha256": "796f16172a7bbf67199790b86930844e4382fe59e68446e9505eabbddbfdcc97" }, "downloads": -1, "filename": "arcgis-rest-query-0.14.tar.gz", "has_sig": false, "md5_digest": "b3adbac131bdcc4bd4535e147a83971f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7606, "upload_time": "2016-02-11T19:54:26", "url": "https://files.pythonhosted.org/packages/43/3b/4bbc1e772e00257f14387b7982b20abee35a56690c7c5b8f12c6cfa9408d/arcgis-rest-query-0.14.tar.gz" } ] }