I'm working with ArcGIS Pro, SDK, try to make an add-in button that can process my selected features one by one. Now I have FeatureLayer feature_layer = layer_made[0] as FeatureLayer; I know this feature_layer already contains my selection, and I can get all selection object ID through GetSelection().GetObjectID() method. I can make a selection by using query filter, e.g feature_layer.select(query).
My question is, how can I convert this selection to feature layer? I know I can use MakeFeatureLayer, but this way will create a feature layer on the map, I just want all this processing finish in backstage. Is any way I can directly convert the selection into a feature layer?
Thank you, Sean, I will try this way. Just wondering, Once I do the copy, can I use the SQL? Just like ArcPy, like:
mva <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit; font-size: 14px;">=</SPAN> Geoprocessing<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN><SPAN class="" style="color: #d74444; border: 0px; font-weight: inherit; font-size: 14px;">MakeValueArray</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">(</SPAN><SPAN class="" style="color: #669900; border: 0px; font-weight: inherit; font-size: 14px;">"Ranger stations"</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">,</SPAN> <SPAN class="" style="color: #669900; border: 0px; font-weight: inherit; font-size: 14px;">@"C:\arcgis\ArcTutor\Editing\Zion.gdb\test","OBJECTID=3"</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">;</SPAN>
Cong,
Try creating a new feature class then copying the features into it. Only the selected features will be copied.
<SPAN class="comment token">//create feature class via GP</SPAN> <SPAN class="keyword token">var</SPAN> mva <SPAN class="operator token">=</SPAN> Geoprocessing<SPAN class="punctuation token">.</SPAN><SPAN class="token function">MakeValueArray</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">@"C:\arcgis\ArcTutor\Editing\Zion.gdb"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"test"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"POINT"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"DISABLED"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"DISABLED"</SPAN><SPAN class="punctuation token">,</SPAN>MapView<SPAN class="punctuation token">.</SPAN>Active<SPAN class="punctuation token">.</SPAN>Map<SPAN class="punctuation token">.</SPAN>SpatialReference<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> cts <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">System<SPAN class="punctuation token">.</SPAN>Threading<SPAN class="punctuation token">.</SPAN>CancellationTokenSource</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> Geoprocessing<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ExecuteToolAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"CreateFeatureclass_management"</SPAN><SPAN class="punctuation token">,</SPAN> mva<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">,</SPAN> cts<SPAN class="punctuation token">.</SPAN>Token<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">,</SPAN> GPExecuteToolFlags<SPAN class="punctuation token">.</SPAN>None<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//copy selected features from a layer in the map to feature class</SPAN> mva <SPAN class="operator token">=</SPAN> Geoprocessing<SPAN class="punctuation token">.</SPAN><SPAN class="token function">MakeValueArray</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Ranger stations"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">@"C:\arcgis\ArcTutor\Editing\Zion.gdb\test"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> Geoprocessing<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ExecuteToolAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"CopyFeatures_management"</SPAN><SPAN class="punctuation token">,</SPAN> mva<SPAN class="punctuation token">,</SPAN><SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">,</SPAN>cts<SPAN class="punctuation token">.</SPAN>Token<SPAN class="punctuation token">,</SPAN><SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">,</SPAN>GPExecuteToolFlags<SPAN class="punctuation token">.</SPAN>None<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>
You might want to create the feature class using a template so the schemas match the selection.
Setting the tool flags to 'none' ensures the output isn't added to the map.
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.