public IReadOnlyList<ElevationSurfaceLayer> GetElevationSurfaceLayers()
Public Function GetElevationSurfaceLayers() As IReadOnlyList(Of ElevationSurfaceLayer)
Return Value
IReadOnlyList {ElevationSurfaceLayer}
public IReadOnlyList<ElevationSurfaceLayer> GetElevationSurfaceLayers()
Public Function GetElevationSurfaceLayers() As IReadOnlyList(Of ElevationSurfaceLayer)
{
//Define a ServiceConnection to use for the new Elevation surface
var serverConnection = new CIMInternetServerConnection
{
Anonymous = true,
HideUserProperty = true,
URL = "https://elevation.arcgis.com/arcgis/services"
};
CIMAGSServiceConnection serviceConnection = new CIMAGSServiceConnection
{
ObjectName = "WorldElevation/Terrain",
ObjectType = "ImageServer",
URL = "https://elevation.arcgis.com/arcgis/services/WorldElevation/Terrain/ImageServer",
ServerConnection = serverConnection
};
//Defines a new elevation source set to the CIMAGSServiceConnection defined above
//Get the elevation surfaces defined in the map
var listOfElevationSurfaces = map.GetElevationSurfaceLayers();
//Add the new elevation surface
var elevationLyrCreationParams = new ElevationLayerCreationParams(serviceConnection);
var elevationSurface = await QueuedTask.Run(() =>
LayerFactory.Instance.CreateLayer<ElevationSurfaceLayer>(elevationLyrCreationParams, map));
}
{
// retrieve the elevation surface layers in the map including the Ground
var surfaceLayers = map.GetElevationSurfaceLayers();
// retrieve the single ground elevation surface layer in the map
var groundSurfaceLayer = map.GetGroundElevationSurfaceLayer();
// determine the number of elevation sources in the ground elevation surface layer
int numberGroundSources = groundSurfaceLayer.Layers.Count;
// get the first elevation source layer from the ground elevation surface layer
var groundSourceLayer = groundSurfaceLayer.Layers.FirstOrDefault();
}
{
// retrieve the elevation surface layers in the map
var surfaceLayers = map.GetElevationSurfaceLayers();
// find a specific elevation surface layer by its URI
var surfaceLayer = surfaceLayers.FirstOrDefault(l => l.Name == "Surface2");
// or use the FindElevationSurfaceLayer method, passing the layer URI
surfaceLayer = map.FindElevationSurfaceLayer("layerUri");
}
{
//Ground will not be removed
map.ClearElevationSurfaceLayers();
ElevationSurfaceLayer surfaceLayer = map.GetElevationSurfaceLayers().FirstOrDefault(l => l.Name == "Surface2");
//Cannot remove ground
map.RemoveLayer(surfaceLayer);
//Ground will not be removed
map.RemoveLayers(map.GetElevationSurfaceLayers());
}
{
await QueuedTask.Run(async () =>
{
var eleLayer = map.GetElevationSurfaceLayers().FirstOrDefault(l => l.Name == "TIN");
//Pass any Geometry type to GetZsFromSurfaceAsync
//Ensure the feature layer is a line layer and is Z aware
var selectedFeatures = featureLayer.GetSelection();
var rowCursor = selectedFeatures.Search();
while (rowCursor.MoveNext())
{
var feature = rowCursor.Current as Feature;
var polyline = feature.GetShape() as Polyline;
var zResult = await map.GetZsFromSurfaceAsync(polyline, eleLayer);
if (zResult.Status == SurfaceZsResultStatus.Ok)
{
var polylineZ = zResult.Geometry as Polyline;
// process the polylineZ
// For example, you can iterate through the points and access their Z values
}
}
});
}
{
// find a specific elevation surface layer
var eleLayer = MapView.Active.Map.GetElevationSurfaceLayers().FirstOrDefault(l => l.Name == "TIN");
Polyline polyline = PolylineBuilderEx.CreatePolyline();
MapPoint mapPoint = MapPointBuilderEx.CreateMapPoint(34, -118, SpatialReferences.WGS84);
List<MapPoint> mapPoints = new List<MapPoint> { mapPoint };
// get the elevation profile for a polyline / set of polylines
// use the specific elevation surface layer
var zResult = await MapView.Active.Map.GetElevationProfileFromSurfaceAsync([polyline], eleLayer);
if (zResult.Status == SurfaceZsResultStatus.Ok)
{
var polylineZ = zResult.Polyline;
// process the polylineZ
}
// get the elevation profile for a set of points
// use the specific elevation surface layer
zResult = await MapView.Active.Map.GetElevationProfileFromSurfaceAsync(mapPoints, eleLayer);
if (zResult.Status == SurfaceZsResultStatus.Ok)
{
var polylineZ = zResult.Polyline;
// process the polylineZ
}
}
{
int numPoints = 20;//Or any number of points you want to interpolate
// use a specific elevation surface
var eleLayer = MapView.Active.Map.GetElevationSurfaceLayers().FirstOrDefault(l => l.Name == "TIN");
// use the default ground elevation surface
MapPoint startPt = MapPointBuilderEx.CreateMapPoint(-130, 20, SpatialReferences.WGS84);
MapPoint endPt = MapPointBuilderEx.CreateMapPoint(-100, 50, SpatialReferences.WGS84);
var result = await MapView.Active.Map.GetElevationProfileFromSurfaceAsync(startPt, endPt, numPoints);
if (result.Status == SurfaceZsResultStatus.Ok)
{
var polylineZ = result.Polyline;
// process the polylineZ
}
// use a specific elevation surface
result = await MapView.Active.Map.GetElevationProfileFromSurfaceAsync(startPt, endPt, numPoints, eleLayer);
if (result.Status == SurfaceZsResultStatus.Ok)
{
var polylineZ = result.Polyline;
// process the polylineZ
}
}
{
if (!MapView.Active.CanShowElevationProfileGraph())
{
return;
}
// use a specific elevation surface
var eleLayer = MapView.Active.Map.GetElevationSurfaceLayers().FirstOrDefault(l => l.Name == "TIN");
// set up the parameters
var profileParams = new ElevationProfileParameters();
profileParams.SurfaceLayer = eleLayer;
profileParams.Densify = true;
// show the elevation profile for a polyline using the params
//Any line
Polyline polyline = PolylineBuilderEx.CreatePolyline();
MapView.Active.ShowElevationProfileGraph([polyline], profileParams);
// show the elevation profile for a set of points using the params
//Some points
MapPoint mapPoint = MapPointBuilderEx.CreateMapPoint(34, -118, SpatialReferences.WGS84);
List<MapPoint> mapPoints = new List<MapPoint> { mapPoint };
MapView.Active.ShowElevationProfileGraph(mapPoints, profileParams);
}
{
int numPoints = 20;
if (!MapView.Active.CanShowElevationProfileGraph())
{
return;
}
// show the elevation profile
// use the default ground elevation surface
MapPoint startPt = MapPointBuilderEx.CreateMapPoint(-130, 20, SpatialReferences.WGS84);
MapPoint endPt = MapPointBuilderEx.CreateMapPoint(-100, 50, SpatialReferences.WGS84);
MapView.Active.ShowElevationProfileGraph(startPt, endPt, numPoints);
// find a specific elevation surface layer
var tinLayer = MapView.Active.Map.GetElevationSurfaceLayers().FirstOrDefault(l => l.Name == "TIN");
// set up the params
var elevProfileParams = new ElevationProfileParameters();
elevProfileParams.SurfaceLayer = tinLayer;
elevProfileParams.Densify = false;
// show the elevation profile using the params
MapView.Active.ShowElevationProfileGraph(startPt, endPt, numPoints, elevProfileParams);
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)