Saving polygon graphics to shapefile

561
3
Jump to solution
09-02-2022 01:05 AM
Labels (2)
FatmaAkdemir
Occasional Contributor II

We have a map application where user defines several polygons with mouse. We want to save these polygon Graphics (which are obviously created with PolygonBuilder class) to a shapefile. After the application is restarted by user, we want to reload these polygons on to the map. Are there any coding examples regarding this issue?

0 Kudos
1 Solution

Accepted Solutions
GuillaumeBelz
Esri Contributor
0 Kudos
3 Replies
GuillaumeBelz
Esri Contributor

Hello,

You can use ShapefileFeatureTable to load and save shapefile. There is an example in samples here: https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Layers/Fea.... And you can use addFeature to add feature on table https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_QMLSamples/EditData/A... 

 

0 Kudos
FatmaAkdemir
Occasional Contributor II

Hi @GuillaumeBelz , thank you for your answer! I looked at those examples and I think they are a little bit different from what I need actually. What I need is to extract polygons from shapefile as a Geometry and add these geometries to a GraphicsOverlay and vice versa. If I extract the geometries as a Feature, is there a way to convert them to Geometry?

0 Kudos
GuillaumeBelz
Esri Contributor

Hi.

Yes, there are setter and getter for geometry in Feature class: https://developers.arcgis.com/qt/cpp/api-reference/esri-arcgisruntime-feature.html#geometry

0 Kudos