how to query (spatial query) a map service that has service directory disabled?

1736
7
Jump to solution
05-13-2019 03:47 PM
JennyHuang1
New Contributor II

Hi all,

I'm new to using the rest API so this might be a stupid question but i just can't figure it out...

i'm using postman to make get request to the below url. my parameter is f=json

https://maps.gov.bc.ca/arcgis/rest/services/mpcm/bcgwpub/MapServer/3

i keep on getting the service directory has been disabled error when i add "query" to the above url string. i know the capabilities supported include query...and if add this service to AGOL's web mapping application it can be used in the query widget...

what i'm hoping to achieve here, is to write python code to do spatial queries against this map service layer.

any help is appreciated!!!

jenny

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Jenny,

   Because the service directory is disabled that means you have to know how to formulate your queries manually. For example:

https://maps.gov.bc.ca/arcgis/rest/services/mpcm/bcgwpub/MapServer/3/query?where=ADMIN_AREA_GROUP_NA...

Now you were specifically asking about doing a spatial query you need these parameters

  1. &geometry= The geometry you are querying by
  2. &geometryType= The input geometries type (i.e. esriGeometryEnvelope)
  3. &inSR= The input geometries spatial reference
  4. &spatialRel=esriSpatialRelIntersects
  5. &outSR= The output geometries spatial reference

View solution in original post

7 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Jenny,

   Because the service directory is disabled that means you have to know how to formulate your queries manually. For example:

https://maps.gov.bc.ca/arcgis/rest/services/mpcm/bcgwpub/MapServer/3/query?where=ADMIN_AREA_GROUP_NA...

Now you were specifically asking about doing a spatial query you need these parameters

  1. &geometry= The geometry you are querying by
  2. &geometryType= The input geometries type (i.e. esriGeometryEnvelope)
  3. &inSR= The input geometries spatial reference
  4. &spatialRel=esriSpatialRelIntersects
  5. &outSR= The output geometries spatial reference
JennyHuang1
New Contributor II

Thanks so much for the quick response, Robert! It's working now

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.

0 Kudos
JennyHuang1
New Contributor II

Hi Robert,

any idea on how to run the query with polygons that have multiple rings? right now i'm thinking of either run the query for each ring geometry (using search cursor) or combine all rings into a multipart polygon. not sure if there's an alternative to these?

thanks very much!

Jenny

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Spatial Queries are only expecting one geometry not an array. So as you have said you will have to create a multipart polygon or run the query on each polygon. I normally use a Geometry service merge to get one multipart polygon.

JennyHuang1
New Contributor II

thanks a lot Robert! i'll look into geometry services

0 Kudos
David_Brooks
MVP Regular Contributor

May i reignite this thread to ask whether it's possible to add a bounding box geomtery to a feature service?

Im have a service that i'd like to constrain and though this would be the url:

https://...........vessels/FeatureServer/0/query?geometryType=esriGeometryEnvelope&geometry=-0.7,53....

but it's not working


David
..Maps with no limits..
0 Kudos