Move a polygon feature by using ArcGIS runtime SDK for .Net

1691
6
10-16-2019 06:41 AM
DharmaRajan
Occasional Contributor

Hi All,

I am using ArcGIS runtime SDK(version 100.6) for .Net. I want to move a polygon feature from one location to other. Kindly  suggest me that how to achieve this.

Tags (1)
0 Kudos
6 Replies
JoeHershman
MVP Regular Contributor

To move something you just need to update the geometry of the existing feature

var feature = //somehow get existing feature

feature.Geometry = myNewGeometry;

await feature.FeatureTable.UpdateFeatureAsync(feature);

In terms of how one would actually allow a user to choose an existing polygon and allow the user to move that depends on many factors.

Thanks,
-Joe
0 Kudos
dotMorten_esri
Esri Notable Contributor

If you want to move it interactively, you can use the SketchEditor which supports dragging geometries around.

If you want to do it programmatically, you can use PolygonBuilder and iterate through the vertices and offset each vertex by a certain amount (this is actually what the SketchEditor does as you're dragging the feature around).

0 Kudos
DharmaRajan
Occasional Contributor

Hi Morten, 

Thank for the response.

Iterating vertices will increase the execution time if the geometry has more number of vertices.

Without iterating through the vertices, is there any option like "ITransform2D method which is available in arcobjects"? So that we can move or rotate the geometry by using inbuilt functionality.

0 Kudos
dotMorten_esri
Esri Notable Contributor

Iterating vertices will increase the execution time if the geometry has more number of vertices.

Sure but it's still extremely quick. Any out-of-the-box method we could provide would have to do the same thing.

Are you seeing a performance issue?

0 Kudos
DharmaRajan
Occasional Contributor

In fact I am looking for the option like to move and rotate and scale. In ArcObjects, by using ITransform2D method we can do almost all these things. Hence I feel it would be useful, if we have the similar method in ArcGIS runtime also.

0 Kudos
dotMorten_esri
Esri Notable Contributor

As mentioned, the SketchEditor has this ability built-in so users can interactively move, scale and rotate geometries.

To do it programmatically you'd just have to move each vertex yourself - there's no out-of-the-box capability for this.

0 Kudos