Hi,
I create the Line shape file in arc map. is it possible for Edit this Shape file in ArcGIS Runtime for .Net.
Yes, this is possible using ShapeFileFeatureTable. You can use the AddFeatureAsync (or AddFeaturesAsync) method to add new features, UpdateFeatureAsync (or UpdateFeaturesAsync) to update existing features, or DeleteFeatureAsync (or DeleteFeaturesAsync) to delete existing features.
Here's a quick example of adding new features:
<SPAN class="comment token">// Create the shapefile table, specifying the path to the shapefile</SPAN> <SPAN class="keyword token">var</SPAN> shapefile <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ShapefileFeatureTable</SPAN><SPAN class="punctuation token">(</SPAN>filePath<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// The shapefile must be loaded to perform operations on it</SPAN> <SPAN class="keyword token">await</SPAN> shapefile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">LoadAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Create the feature, specyfing the new feature's attributes and geometry</SPAN> <SPAN class="keyword token">var</SPAN> feature <SPAN class="operator token">=</SPAN> shapefile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CreateFeature</SPAN><SPAN class="punctuation token">(</SPAN>attributes<SPAN class="punctuation token">,</SPAN> geometry<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Add the newly created feature to the shapefile</SPAN> <SPAN class="keyword token">await</SPAN> shapefile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">AddFeatureAsync</SPAN><SPAN class="punctuation token">(</SPAN>feature<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
And editing existing features:
<SPAN class="comment token">// Create the shapefile table, specifying the path to the shapefile</SPAN> <SPAN class="keyword token">var</SPAN> shapefile <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ShapefileFeatureTable</SPAN><SPAN class="punctuation token">(</SPAN>filePath<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// The shapefile must be loaded to perform operations on it</SPAN> <SPAN class="keyword token">await</SPAN> shapefile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">LoadAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Create the feature, specyfing the new feature's attributes and geometry</SPAN> <SPAN class="keyword token">var</SPAN> feature <SPAN class="operator token">=</SPAN> shapefile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CreateFeature</SPAN><SPAN class="punctuation token">(</SPAN>attributes<SPAN class="punctuation token">,</SPAN> geometry<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Add the newly created feature to the shapefile</SPAN> <SPAN class="keyword token">await</SPAN> shapefile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">AddFeatureAsync</SPAN><SPAN class="punctuation token">(</SPAN>feature<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Query the shapefile to retrieve the feature or features to edit. The query</SPAN> <SPAN class="comment token">// parameters can specify object IDs, attribute values, search geometries, and more</SPAN> <SPAN class="keyword token">var</SPAN> queryResult <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">await</SPAN> shapefile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">QueryFeaturesAsync</SPAN><SPAN class="punctuation token">(</SPAN>queryParameters<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// For this example, just get the first feature from the result</SPAN> <SPAN class="keyword token">var</SPAN> feature <SPAN class="operator token">=</SPAN> queryResult<SPAN class="punctuation token">.</SPAN><SPAN class="token function">First</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Update the feature's geometry</SPAN> feature<SPAN class="punctuation token">.</SPAN>Geometry <SPAN class="operator token">=</SPAN> newGeometry<SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Update attribute values. Note that the type of the new value must match the type</SPAN> <SPAN class="comment token">// of the attribute field being updated (e.g. string, integer, date/time, etc)</SPAN> feature<SPAN class="punctuation token">.</SPAN>Attributes<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"SomeStringFieldName"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> <SPAN class="string token">"New attribute value!"</SPAN><SPAN class="punctuation token">;</SPAN> feature<SPAN class="punctuation token">.</SPAN>Attributes<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"SomeDateFieldName"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> DateTimeOffset<SPAN class="punctuation token">.</SPAN>UtcNow<SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Apply the edits to the shapefile</SPAN> <SPAN class="keyword token">await</SPAN> shapefile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">UpdateFeatureAsync</SPAN><SPAN class="punctuation token">(</SPAN>feature<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Hope this helps.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.