SPATIALQUERY  Examples

Used in:  CONFIG   REQUEST  
Servers:  Image   Query   Feature   Extract   ArcMap  
Parent elements:  BUFFER   GET_FEATURES   LAYER   LAYERDEF  

<SPATIALQUERY Attribute Description Table


     When using ArcMap Server:
     featurelimit ="integer"  [All that meet criteria]
     searchorder ="optimize | spatialfirst | attributefirst"  [optimize]
     subfields ="#ALL# | #ID# | #SHAPE# | Other fields in database"  [#ALL#]
     where ="string"

     When using Image, Extract, Query, or Feature Server:
     accuracy ="Distance between points"  [0]
     featurelimit ="integer"  [All that meet criteria]
     joinexpression ="string"
     jointables ="string"
     searchorder ="optimize | spatialfirst | attributefirst"  [optimize]
     subfields ="#ALL# | #ID# | #SHAPE# | Other fields in database"  [#ALL#]
     where ="string"
>


     When parent element is BUFFER:
     <SPATIALFILTER... />

     When parent element is GET_FEATURES:
     <BUFFER... />
     <FEATURECOORDSYS... />
     <FILTERCOORDSYS... />
     <SPATIALFILTER... />

     When parent element is LAYER and LAYERDEF in GET_IMAGE:
     <BUFFER... />
     <SPATIALFILTER... />

     When parent element is LAYER in CONFIG:
     <FILTERCOORDSYS... />
     <SPATIALFILTER... />

</SPATIALQUERY >


Description:


Restrictions:


Notes:


Attribute Descriptions for SPATIALQUERY:

Attribute Usage Back to Top
accuracy 1 Used in GET_FEATURES requests. Within a feature, generalizes points based on the distance specified and the resolution of the image. Units are the same as the service.
featurelimit 2 Used in GET_FEATURES requests. Maximum number of features to be extracted that meet criteria. The value for this featurelimit overrides any featurelimit set in GET_FEATURES.
joinexpression 3 Used for join tables with DBF files only; jointables must be filled to contain list of tables used; not required when a jointable is done on ArcSDE.

String must form expression: "To=[master table column which will be used for joining], From=[defines a join table column which will be joined], Type=[exact or scan]".
jointables 4 List of joined table names separated by blank spaces; for ArcSDE, table name is full name including database name (e.g., DATA.STATE); for shapefiles, use the DBF filename without the extension (e.g., STATES).
searchorder 5 Used with ArcSDE layers only. Determines whether the attribute or spatial part of an ArcSDE query is processed first. "Spatialfirst" processes the spatial part of the query before the attribute part. "Attributefirst" processes the attribute part of the query first. If "optimize" is used, ArcSDE will make the judgment whether to pick "spatialfirst" or "attributefirst".
subfields 6 List of fields available for querying or extracting. Multiple fields can be included in the subfields list. Fields must be separated by blank space.

If subfields is not used, all fields are returned. If subfields is used, only listed fields are returned. The subfields #SHAPE# or #ALL# must be included if geometry is to be returned in a FEATURES response. In addition, the GET_FEATURES geometry attribute must be set to true.

The subfields list can include fields from the layer table or a joined table.
  • For shapefiles with no joined tables, the field can be referenced using the short format.
    field="AREA"
  • For shapefiles with joined tables, the name of the joined table must be included along with the field.
    field="JOINEDTABLE.AREA"
  • For ArcSDE layers with or without joined tables, the field must be referenced using the full long format.
    field="ARCSDENAME.TABLE.AREA"
where 7 Defines "where" part of SQL expression. Required when jointables attribute for ArcSDE tables is used. See Notes section for information on querying dates.
 

Examples for SPATIALQUERY:

Example 1: Setting a spatial query in a GET_IMAGE request. Note in this example that the DATASET fromlayer is "Countries". This refers to the LAYER id in the map configuration file, not the LAYER name. Back to Top
<?xml version="1.0" encoding="UTF-8"?>
<ARCXML version="1.1">
<REQUEST>
  <GET_IMAGE>
    <PROPERTIES>
      <ENVELOPE minx="-180" miny="-90" maxx="180" maxy="90" />
      <IMAGESIZE width="643" height="502" />
    </PROPERTIES>
    <LAYER type="featureclass" name="select layer" visible="true" id="300">
      <DATASET fromlayer="Countries" />
      <SPATIALQUERY>
        <SPATIALFILTER relation="area_intersection">
          <ENVELOPE maxy="30" maxx="30" miny="0" minx="0" />
        </SPATIALFILTER>
      </SPATIALQUERY>
      <SIMPLERENDERER>
        <SIMPLEPOLYGONSYMBOL fillcolor="255,255,255" filltype="cross" />
      </SIMPLERENDERER>
    </LAYER>
  </GET_IMAGE>
</REQUEST>
</ARCXML>

Example 2: Setting a spatial query in a GET_FEATURES request. Back to Top
<?xml version="1.0" encoding="UTF-8"?>
<ARCXML version="1.1">
    <REQUEST>
      <GET_FEATURES outputmode="xml" geometry="false">
        <LAYER id="Countries" />
           <SPATIALQUERY >
             <SPATIALFILTER relation="area_intersection">
                <POLYGON>
                <RING>
                   <POINT x="-87.73640582356195" y="41.84726275" />
                   <POINT x="-87.73640582356195" y="41.884308250000004" />
                   <POINT x="-87.68764017643805" y="41.884308250000004" />
                   <POINT x="-87.68764017643805" y="41.84726275" />
                   <POINT x="-87.73640582356195" y="41.84726275" />
                </RING>
                </POLYGON>
             </SPATIALFILTER>
           </SPATIALQUERY>
      </GET_FEATURES>
    </REQUEST>
</ARCXML>

Example 3: Joining DBF files in CONFIG. Back to Top
<?xml version="1.0" encoding="UTF-8"?>
<ARCXML version="1.1">
  <CONFIG>
    <ENVIRONMENT>
      <LOCALE country="US" language="en" variant="" />
      <UIFONT color="0,0,0" name="Arial" size="12" style="regular" />
      <SCREEN dpi="96" />
    </ENVIRONMENT>
    <MAP>
      <PROPERTIES>
        <ENVELOPE minx="-178.215027" miny="18.924782" maxx="-66.969849" maxy="71.406647" name="Initial_Extent" />
        <MAPUNITS units="decimal_degrees" />
      </PROPERTIES>
      <WORKSPACES>
         <SHAPEWORKSPACE name="shp_ws-0" directory="<path to USA ESRIDATA>" />
      </WORKSPACES>

      <LAYER type="featureclass" name="counties" visible="true" id="0">
        <DATASET name="COUNTIES" type="polygon" workspace="shp_ws-0" />

          <SPATIALQUERY where="counties.STATE_NAME=&apos;Nevada&apos;" jointables="countyinfo" joinexpression="To=[counties.FIPS],From=[countyinfo.FIPS],Type=[scan]" >  
            <SPATIALFILTER relation="area_intersection">
                  <ENVELOPE minx="-126" miny="31" maxx="-108" maxy="46" />
            </SPATIALFILTER>
          </SPATIALQUERY>

        <SIMPLERENDERER>
          <SIMPLEPOLYGONSYMBOL fillcolor="27,127,27" filltype="solid" />
        </SIMPLERENDERER>
      </LAYER>

    </MAP>
  </CONFIG>
</ARCXML>

Example 4: Joining ArcSDE tables in CONFIG. Back to Top
<?xml version="1.0" encoding="UTF-8"?>
<ARCXML version="1.1">
  <CONFIG>
    <ENVIRONMENT>
      <LOCALE country="US" language="en" variant="" />
      <UIFONT color="0,0,0" name="Arial" size="12" style="regular" />
      <SCREEN dpi="96" />
    </ENVIRONMENT>
    <MAP>
      <PROPERTIES>
      <ENVELOPE minx="-175.2" miny="-90.0" maxx="179.2" maxy="83.6" name="Initial_Extent" />
      <MAPUNITS units="decimal_degrees" />
      </PROPERTIES>
      <WORKSPACES>
      <SDEWORKSPACE name="sde_ws-4" server="sierra" instance="esri_sde" database="" user="world_data" encrypted="true" password="LXEMUR" />
      </WORKSPACES>
      <LAYER type="featureclass" name="WORLD.CITY" visible="true" id="0">
      <DATASET name="WORLD.CITY" type="point" workspace="sde_ws-4" />

        <SPATIALQUERY where="WORLD.CITY.FIPS_CNTRY = WORLD.COUNTRYP.FIPS_CNTRY and WORLD.COUNTRYP.FIPS_CNTRY=&apos;CA&apos; " jointables="WORLD.COUNTRYP" >  
          <SPATIALFILTER relation="area_intersection">
           <ENVELOPE maxy="30" maxx="30" miny="0" minx="0" />
          </SPATIALFILTER>
        </SPATIALQUERY>

      <SIMPLERENDERER>
        <SIMPLEMARKERSYMBOL color="27,227,27" width="8" />
      </SIMPLERENDERER>
      </LAYER>
    </MAP>
  </CONFIG>
</ARCXML>

Example 5: Using both an attribute query and a spatial filter in CONFIG. Back to Top
<?xml version="1.0" encoding="UTF-8"?>
<ARCXML version="1.1">
  <CONFIG>
    <ENVIRONMENT>
      <LOCALE country="US" language="en" variant="" />
      <UIFONT color="0,0,0" name="Arial" size="12" style="regular" />
      <SCREEN dpi="96" />
    </ENVIRONMENT>
    <MAP dynamic="true">
      <PROPERTIES>
        <ENVELOPE minx="-180" miny="-90" maxx="180" maxy="90" name="Initial_Extent" />
      <MAPUNITS units="decimal_degrees" />
      </PROPERTIES>
      <WORKSPACES>
        <SHAPEWORKSPACE name="shp_ws-0" directory="<path to WORLD ESRIDATA>"/>
      </WORKSPACES>
      <LAYER type="featureclass" name="CITIES" visible="true" id="2">
      <DATASET name="CITIES" type="point" workspace="shp_ws-0" />
      <SPATIALQUERY where="POPULATION &gt; 2000000">
        <SPATIALFILTER relation="area_intersection">
          <ENVELOPE maxy="30" maxx="30" miny="0" minx="0" />
        </SPATIALFILTER>
      </SPATIALQUERY>
      <SIMPLERENDERER>
        <SIMPLEMARKERSYMBOL type="square" width="5" />
      </SIMPLERENDERER>
      </LAYER>
    </MAP>
  </CONFIG>
</ARCXML>

Example 6: Using a date query in a GET_FEATURES request. Back to Top
<?xml version="1.0" encoding="UTF-8" ?>
<ARCXML version="1.1">
  <REQUEST>
    <GET_FEATURES featurelimit="25" beginrecord="0" outputmode="xml" geometry="false" envelope="true" compact="true">
      <LAYER id="0" />
      <SPATIALQUERY subfields="#ALL#" where="MYDATE = {ts '2000-01-07'}" />
    </GET_FEATURES>
  </REQUEST>
</ARCXML>