Creates a spatial query which performs a spatial search for features in the supplied feature class and have the option to a LSO apply an attribute query via a WHERE clause.
///<summary>creates a spatial query which performs a spatial search for features in the supplied feature class and have the option To also apply an attribute query via a WHERE clause.</summary>/// ///<param name= "Featureclass" >An ESRI. ArcGIS.Geodatabase.IFeatureClass</param>///<param name= "Searchgeometry" >An ESRI. ArcGIS.Geometry.IGeometry (high-level geometries can be used)</param>///<param name= "SpatialRelation" >An ESRI. ArcGIS.Geodatabase.esriSpatialRelEnum (e.g., esrispatialrelintersects)</param>///<param name= "Whereclause" >A System.String, (e.g., "city_name = ' Redlands '").</param>/// ///<returns>An ifeaturecursor holding the results of the query would be returned.</returns>/// ///<remarks>Call the Spatialquery method by passing in a reference to the Feature Class, a Geometry used for the search and the SP Atial operation to be preformed. An exmaple of a spatial opertaion would is intersects (e.g., esrispatialrelenum.esrispatialrelcontains). If you would a-return everything found by the spatial operation use "" for the WHERE clause. Optionally a whereclause (e.g. "Income >") maybe applied if desired. The SQL syntax used to specify the WHERE clause are the same as that of the underlying database holding the data.</remarks> PublicESRI. ArcGIS.Geodatabase.IFeatureCursor Performspatialquery (ESRI. ArcGIS.Geodatabase.IFeatureClass Featureclass, ESRI. ArcGIS.Geometry.IGeometry Searchgeometry, ESRI. ArcGIS.Geodatabase.esriSpatialRelEnum spatialrelation, System.String whereclause) {//Create a spatial query filterESRI. ArcGIS.Geodatabase.ISpatialFilter Spatialfilter =NewESRI. ArcGIS.Geodatabase.SpatialFilterClass (); //Specify the geometry to query withSpatialfilter.geometry =Searchgeometry; //Specify what's the geometry field is called on the Feature Class so we'll be querying againstSystem.String Nameofshapefield =Featureclass.shapefieldname; Spatialfilter.geometryfield=Nameofshapefield; //specify the type of spatial operation to useSpatialfilter.spatialrel =spatialrelation; //create the WHERE statementSpatialfilter.whereclause =Whereclause; //perform the query and use a cursor to the resultsESRI. ArcGIS.Geodatabase.IQueryFilter QueryFilter =NewESRI. ArcGIS.Geodatabase.QueryFilterClass (); QueryFilter=(ESRI. ArcGIS.Geodatabase.IQueryFilter) Spatialfilter; ESRI. ArcGIS.Geodatabase.IFeatureCursor Featurecursor= Featureclass.search (QueryFilter,false); returnfeaturecursor;}
ArcGIS Spatial Query