Skip to content

Instantly share code, notes, and snippets.

@kf4x
Last active December 18, 2015 01:28
Show Gist options
  • Save kf4x/5703493 to your computer and use it in GitHub Desktop.
Save kf4x/5703493 to your computer and use it in GitHub Desktop.
Example query of ABQ data JSON

Instead of posting links like ABQ did, I'll explain how the server works that way you can build your own queries.

###YouTube Made 2 videos to get started

YouTube Playlist ABQOpenData

Root Folder

http://coagisweb.cabq.gov/arcgis/rest/services

#Breaking it down Using this template we will fill in the missing variables

http://coagisweb.cabq.gov/arcgis/rest/services/{folder}/{mapserver}/MapServer/{layer}/query

Start here
we want to choose the {folder} http://coagisweb.cabq.gov/arcgis/rest/services/
I'll choose 'public'

http://coagisweb.cabq.gov/arcgis/rest/services/public

Next
we want to choose a {mapserver} http://coagisweb.cabq.gov/arcgis/rest/services/public
I'll choose 'recreation'

http://coagisweb.cabq.gov/arcgis/rest/services/public/recreation/MapServer/

Next
Here we have to choose our layer. Go to the URL we just created. below

http://coagisweb.cabq.gov/arcgis/rest/services/public/recreation/MapServer

Find the bolded word "Layers" and pick one.

NOTE: The integer next to the title will be used in the URL

I'll choose 'parks (0)'

http://coagisweb.cabq.gov/arcgis/rest/services/public/recreation/MapServer/0/

Almost
tag a 'query' on and your ready to go

http://coagisweb.cabq.gov/arcgis/rest/services/public/recreation/MapServer/0/query

#Examples NOT using the query generator

notice the where= ' ' statements

getting all landfills

http://coagisweb.cabq.gov/arcgis/rest/services/public/environmentalissues/MapServer/2/query?where=OBJECTID>1&f=pjson

getting specific bus route Eubank fullviewer is the table with everything(i guess) layer 19 is transit routes

http://coagisweb.cabq.gov/arcgis/rest/services/public/fullviewer/MapServer/19/query?where=RTNAME='Eubank'&f=pjson

#Getting Parks baseUrl http://coagisweb.cabq.gov/arcgis/rest/services/public/recreationMapServer/0

ugly generated query

http://coagisweb.cabq.gov/arcgis/rest/services/public/recreation/MapServer/0/query?where=1%3D1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&f=pjson

could be cut shown as

http://coagisweb.cabq.gov/arcgis/rest/services/public/recreation/MapServer/0/query?where=1%3D1&f=pjson

You have this url.
It is not actually West Bluff park it still returns many other parks it's just performing a "text" serach and as a result is returning too much data (takes too much time)

http://coagisweb.cabq.gov/arcgis/rest/services/public/recreation/MapServer/0/query?where=1%3D1&text=WEST+BLUFF&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&f=pjson

more accurate way use where statement and text param should be blank perferably left out

KEY is: where=UPPER(PARKNAME)=UPPER('west bluff')

http://coagisweb.cabq.gov/arcgis/rest/services/public/recreation/MapServer/0/query?where=UPPER(PARKNAME)=UPPER('west bluff')&f=pjson

###XY to Lat Long add this out spatial reference param (should work on all)

&outSR=4326

###Therefore
this

http://coagisweb.cabq.gov/arcgis/rest/services/public/recreation/MapServer/0/query?where=UPPER(PARKNAME)=UPPER('west bluff')&f=pjson  

becomes this

http://coagisweb.cabq.gov/arcgis/rest/services/public/recreation/MapServer/0/query?where=UPPER(PARKNAME)=UPPER('west bluff')&outSR=4326&f=pjson

#Param List Doc list of parameters and their definitions documention from ArcGIS

http://mapservices.nps.gov/arcgis/sdk/rest/query.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment