Dear superiors:
Now I have a question to request ,please lost several minutes.
Q1: How can i split a polygon
now there is a polygon A,when i draw a line, then the polygon split to two (A1,A2).
pic one
pic two
Q2:How can i merge serveral polygon to one
now there is two or more than two polygons next (A1,A2) ,when I press Ctrl key ,then the polygons all be choiced ,how can I merge then to one(A)
like the picture up pic two ------> pic one
Solved! Go to Solution.
You'll need the geometryService:
geometryservice-amd | API Reference | ArcGIS API for JavaScript
This will get you geometries and you can update/create your features for saving as required. Here's how I've done this.
Split:
- Start with a selected polygon (know what you're splitting)
- Use the draw toolbar to get a line (onDrawEnd Event)
- I use the GeometryService->trimExtend to make sure the line will cut completely
- Use geometryService->cut([selectedPoly], newLine, ...) to get two new polys
- save the new polys (add two new and delete old, or whatever works for your data)
Merge
- Select multiple polygons
- geometryService->union([selectedPolys]) to get one poly
- save the new poly (delete the old, add new, etc).
I haven't touched on managing the attributes, but that shouldn't be bad once you have the geometries:
there should be a 'merge' option in the menu on your editor toolbar. Make sure you have only features selected from the same layer otherwise the merge will not work.
Dear Mr Bart Smit:
Thanks very much.
Is it esri/dijit/editing/Editor? Yes in a layer, How can i split the polygon?
Best wishes
hhm, I'm afraid I spoke too soon. I can't find any code that has merge/split. All I can find is vertex/move/snap etc .. It might have been a geoprocessing service that offered that functionality. Or it might not have been esri stuff.. I can't recall the example. I'm sorry.
Dear Bart Smit:
Also thanks to you。
Superiors:
My function is in javascript Of html ,not desktop, thanks very much。
U can use the cut polygon tool
Dear monyrothly:
Thanks very much. But I still not understand, Can you give the component in esri,
Wish you happy every day.
You'll need the geometryService:
geometryservice-amd | API Reference | ArcGIS API for JavaScript
This will get you geometries and you can update/create your features for saving as required. Here's how I've done this.
Split:
- Start with a selected polygon (know what you're splitting)
- Use the draw toolbar to get a line (onDrawEnd Event)
- I use the GeometryService->trimExtend to make sure the line will cut completely
- Use geometryService->cut([selectedPoly], newLine, ...) to get two new polys
- save the new polys (add two new and delete old, or whatever works for your data)
Merge
- Select multiple polygons
- geometryService->union([selectedPolys]) to get one poly
- save the new poly (delete the old, add new, etc).
I haven't touched on managing the attributes, but that shouldn't be bad once you have the geometries: