In this topic
- Querying an image service using an image query filter
- Querying an image service using a spatial filter
- Querying an image service using an attribute query filter
Querying an image service using an image query filter
The following code shows how to query an image service based on pixel size and return a set of feature IDs:
[C#] public static IFIDSet QueryIS_PixelSize(IImageServer imageServer)
{
//Cast:
IImageServer3 imageServer3=(IImageServer3)imageServer;
//Create a filter using a pixel size of 0.28/0.28.
IImageQueryFilter imageQueryFilter=new ImageQueryFilterClass();
IPoint pixelSize=new PointClass();
pixelSize.PutCoords(0.28, 0.28);
imageQueryFilter.PixelSize=pixelSize;
//Return feature IDs.
IFIDSet fidSet=imageServer3.GetCatalogItemIDs((IQueryFilter)imageQueryFilter);
return fidSet;
}
[VB.NET] Public Shared Function QueryIS_PixelSize(ByVal imageServer As IImageServer) As IFIDSet
'Cast:
Dim imageServer3 As IImageServer3=CType(imageServer, IImageServer3)
'Create a filter using a pixel size of 0.28/0.28.
Dim imageQueryFilter As IImageQueryFilter=New ImageQueryFilterClass()
Dim pixelSize As IPoint=New PointClass()
pixelSize.PutCoords(0.28, 0.28)
imageQueryFilter.PixelSize=pixelSize
'Return feature IDs.
Dim fidSet As IFIDSet=imageServer3.GetCatalogItemIDs(CType(imageQueryFilter, IQueryFilter))
Return fidSet
End Function
Querying an image service using a spatial filter
The following code shows how to query an image service based on geometry and return a record set:
[C#] public static IRecordSet QueryIS_Spatial(IImageServer imageServer, IGeometry
queryGeometry)
{
//Cast:
IImageServer3 imageServer3=(IImageServer3)imageServer;
//Create a spatial filter using the provided geometry.
ISpatialFilter spatFilter=new ImageQueryFilterClass();
spatFilter.Geometry=queryGeometry;
spatFilter.SpatialRel=esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects;
//Return a record set.
IRecordSet recordSet=imageServer3.GetCatalogItems((IQueryFilter)spatFilter);
return recordSet;
}
[VB.NET] Public Shared Function QueryIS_Spatial(ByVal imageServer As IImageServer, ByVal queryGeometry As IGeometry) As IRecordSet
'Cast:
Dim imageServer3 As IImageServer3=CType(imageServer, IImageServer3)
'Create a spatial filter using the provided geometry.
Dim spatFilter As ISpatialFilter=New ImageQueryFilterClass()
spatFilter.Geometry=queryGeometry
spatFilter.SpatialRel=esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects
'Return a record set.
Dim recordSet As IRecordSet=imageServer3.GetCatalogItems(CType(spatFilter, IQueryFilter))
Return recordSet
End Function
Querying an image service using an attribute query filter
The following code shows how to use an attribute query to return an item count of primary rasters:
[C#] public static int QueryIS_Attribute(IImageServer imageServer)
{
//Cast:
IImageServer3 imageServer3=(IImageServer3)imageServer;
//Create an attribute filter that queries primary rasters.
IQueryFilter attFilter=new ImageQueryFilterClass();
attFilter.WhereClause="Category=1";
//Return the primary rasters's count.
int count=imageServer3.GetCatalogItemCount(attFilter);
return count;
}
[VB.NET] Public Shared Function QueryIS_Attribute(ByVal imageServer As IImageServer) As Integer
'Cast:
Dim imageServer3 As IImageServer3=CType(imageServer, IImageServer3)
'Create an attribute filter that queries primary rasters.
Dim attFilter As IQueryFilter=New ImageQueryFilterClass()
attFilter.WhereClause="Category=1"
'Return the primary rasters's count.
Dim Count As Integer=imageServer3.GetCatalogItemCount(attFilter)
Return Count
End Function
To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
- ESRI.ArcGIS.Carto
- ESRI.ArcGIS.Server
- ESRI.ArcGIS.System (ESRI.ArcGIS.esriSystem)
- ESRI.ArcGIS.Geodatabase
- ESRI.ArcGIS.Geometry
Development licensing | Deployment licensing |
---|---|
ArcGIS for Desktop Advanced | ArcGIS for Desktop Advanced |
ArcGIS for Desktop Standard | ArcGIS for Desktop Standard |
ArcGIS for Desktop Basic | ArcGIS for Desktop Basic |
Engine Developer Kit | Engine |