Select to view content in your preferred language

How do I get a count of all features in a layer/service?

920
8
09-30-2010 02:09 AM
TonyCollins
Regular Contributor
Is there a way to query a service or service layer to simply get a count of the matching features?

I know I could go grab the lot and get it that way, but my service is limited to 500 results and there are way more features than that. I do not want to change this limit as there are other applications that utilize this service and I simply want the count value and don't care about the attribute data.

So simply, is there a way to just do a SELECT COUNT(whatever) FROM [Service] or something if you get my meaning?
Tags (2)
0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Emeritus
Tony,

     In the 2.1 API take at look at executeForIds method of the QueryTask.
0 Kudos
TonyCollins
Regular Contributor
Tony,

     In the 2.1 API take at look at executeForIds method of the QueryTask.



I can't get this to work at all. I always get a zero length array back, whereas if I switch to execute I get a nice featureSet back so the query must be right!?

I don't need Version 10 of server do I?

Thanks Robert.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Tony,

    I am pretty sure you do not need Server 10. Although just because execute is returning a featureset doe not mean that the feature set has any features in it. Can you check the length of the returned featureset?what does your query look like?
0 Kudos
TonyCollins
Regular Contributor
Tony,

    I am pretty sure you do not need Server 10. Although just because execute is returning a featureset doe not mean that the feature set has any features in it. Can you check the length of the returned featureset?what does your query look like?


Hi Robert,

FeatureSet is fine, in this particular example it contains 53 objects so I figured a switch to the executeForIds method would return an Array of the same length!?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Tony,

   I was able to duplicate your results when using a 9.3.1 Server so it Must only work with a 10 Server, although I don't see where the API documents this.
0 Kudos
DasaPaddock
Esri Regular Contributor
Yes, this does require server 10 since it uses a new returnIdsOnly parameter.

Reference:
http://sampleserver3.arcgisonline.com/ArcGIS/SDK/REST/query.html
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Dasa,

    You guys might want to put something in the documentation about the ArcGIS Server 10 requirement. I did not see anything about this in the documentation unless I overlooked it.
0 Kudos
TonyCollins
Regular Contributor
Ahh thank you very much guys. At least that answers my question!

I Installed a test server on version 10 today and desktop too (to test this stuff) only to find Catalog can't manage a 9.3.1 server so I can't manage a version 10 and a 9.3.1 server from one machine!!! That is REALLY annoying/impossible for trying to migrate!!!! :mad:
0 Kudos