Calculate a viewshed against terrain using a geoprocessing service.
After the geoprocessing task finishes loading (the spinner will stop), click anywhere on the map to generate a viewshed at that location. A viewshed will be calculated using the service's default distance of 15km.
To create a viewshed from a geoprocessing service:
- Create a
GeoprocessingTask
with the URL set to the viewshed endpoint of a geoprocessing service . - Create a
FeatureCollectionTable
and add a newFeature
whose geometry is thePoint
where you want to create the viewshed. - Make
GeoprocessingParameters
with an input for the viewshed operationparameters.getInputs().put("Input_Observation_Point", new GeoprocessingFeatures(featureCollectionTable))
. - Use the
GeoprocessingTask
to create aGeoprocessingJob
with the parameters. - Start the job and wait for it to complete and return a
GeoprocessingResult
. - Get the resulting
GeoprocessingFeatures
usinggeoprocessingResult.getOutputs().get("Viewshed_Result")
. - Iterate through the viewshed features in
geoprocessingFeatures.getFeatures()
to use their geometry or display the geometry in a graphic.
- FeatureCollectionTable
- GeoprocessingFeatures
- GeoprocessingJob
- GeoprocessingParameters
- GeoprocessingResult
- GeoprocessingTask