This document is archived and information here might be outdated.  Recommended version.


How to perform mensuration on an image service (ArcObjects .NET 10.5 SDK)

How to perform mensuration on an image service


Summary
This topic demonstrates how to perform mensuration on an image service (new at ArcGIS 10.1).

Performing mensuration on an image service

The following code example demonstrates how to measure the height of a building using locations of building bottom and top:
[C#]
public static void Measure(IImageServer4 imageServer)
{
    //Define building bottom.
    IPoint fromPoint=new PointClass();
    fromPoint.X= - 117.29944857;
    fromPoint.Y=34.15586888;
    fromPoint.SpatialReference=imageServer.ServiceInfo.SpatialReference;

    //Define building top.
    IPoint toPoint=new PointClass();
    toPoint.X= - 117.29940048;
    toPoint.Y=34.15589815;
    toPoint.SpatialReference=imageServer.ServiceInfo.SpatialReference;

    //Measure height.
    IImageServerMeasureResult result=imageServer.Measure(fromPoint, toPoint, null,
        null, esriMensurationOperation.esriMensurationHeightFromBaseAndTop);
    Console.WriteLine("{0} +/- {1} {2}", (Double)result.Measurement.GetProperty(
        "Height"), (Double)result.Measurement.GetProperty("HeightUncertainty"), 
        (string)result.Measurement.GetProperty("LinearUnit"));
}
[VB.NET]
Public Shared Sub Measure(ByVal imageServer As IImageServer4)
'Define building bottom.
Dim fromPoint As IPoint=New PointClass()
fromPoint.X=-117.29944857
fromPoint.Y=34.15586888
fromPoint.SpatialReference=imageServer.ServiceInfo.SpatialReference

'Define building top.
Dim toPoint As IPoint=New PointClass()
toPoint.X=-117.29940048
toPoint.Y=34.15589815
toPoint.SpatialReference=imageServer.ServiceInfo.SpatialReference

'Measure height.
Dim result As IImageServerMeasureResult=imageServer.Measure(fromPoint, toPoint, Nothing, Nothing, esriMensurationOperation.esriMensurationHeightFromBaseAndTop)
Console.WriteLine("{0} +/- {1} {2}", DirectCast(result.Measurement.GetProperty("Height"), Double), DirectCast(result.Measurement.GetProperty("HeightUncertainty"), Double), DirectCast(result.Measurement.GetProperty("LinearUnit"), String))
End Sub


See Also:

How to make measurements from images




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):
Development licensing Deployment licensing
ArcGIS Desktop Advanced ArcGIS Desktop Advanced
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Basic ArcGIS Desktop Basic
Engine Developer Kit Engine