Statistics and SpatialFilter

2449
5
04-23-2012 08:09 AM
olivierdev
New Contributor III
With ArcGIS for Server 10.1 REST API, it seems that when performing a query with oustatistics with a spatial filter (Input Geometry and Spatial Relationship), the spatial filter is not applied.
The query is done on all the features, not only the ones matching the spatial filter.

Is it supposed to be like this (strange) or is it a bug that will be corrected in the final release?

Thanks in advance.

olivier
0 Kudos
5 Replies
olivierdev
New Contributor III
I've just found out that on the REST API help :
"When using outStatistics the only other parameters that will be used are groupByFieldsForStatistics, orderByFields, text, time, and where. "
I guess this answers my question.
Not supported, and works as required.
That's too bad...
0 Kudos
OttarViken_Valvåg
New Contributor III
Does anybody have any suggestions for how to work around this limitation? What would be the easiest way to calculate statistics in combination with a spatial query?

Some options that I can see:

1. Query all the data and calculate the statistics client-side - very bandwidth intensive, poor performance
2. Do a spatial query for object ids, then do a statistics query with object ids in the where clause. I imagine one would run into issues with long where clauses quickly.
3. A custom SOE to do the calculation - this seems like it will yield the best performance but seems like a needlessly complex solution for a simple problem.

EDIT: And I suppose a geoprocessing service is a fourth alternative. I'm a bit doubtful on the performance I'd get, though.

Suggestions?
0 Kudos
OttarViken_Valvåg
New Contributor III
By the way... Why is this forum named "ArcGIS Server (10.0 and prior) REST API" - is there a new forum for 10.1 questions?
0 Kudos
TanuHoque
Esri Regular Contributor
This is a known limit at 10.1 that SpatialFilter does not get used while querying for stats off a mapserver, only attribute query is supported.
We have this in 10.1 SP1 list of enhancements to be supported.

In the meantime, here are workarounds:

  1. what valvag proposed as #2.


    • It will not perform well since you need to make two requests

    • you can also use 'OBJECTID in (1,2,3...)' instead of 'OBJECTID = 1 or OBJECTID = 2 ...' as a whereclause

OR,
  • if your underlying RDBMS supports Spatial data natively, then


    • store geometries/shapes in DB's native storage type

    • in your web app, construct a SQL Statement that includes a spatial operation and geometry (conformed to their specs)

    • pass that sql as a where clause to query operation.


    0 Kudos
    GiedriusStanevi_ius
    New Contributor
    Hi,

    With 10.1 we implemented solution with 2 queries: one for objectIds and second for statistics. Now with 10.1 SP1 we are testing direct query for statistics. When using data stored in Oracle DB, the later solution is faster and thats great. However when using file GDB, performance is poor and the first implementation is faster, although not as fast as with Oracle. I wonder if there is anything we can tune up in the file GDB to get better performance, because we dont want to use Oracle just for this one case
    0 Kudos