How to working with geometry in editing session with Python?

2303
3
Jump to solution
09-15-2014 10:01 AM
SaidAkif
New Contributor III


I have to copy lot of polygons (without attributs) for a shapefile to another in an editing session.

I want to do this with python scripting in python windows (ArcGIS 10.1).

I selected each polygon of interest and now I am doing this work just by Copy/Paste commands?

Some time the copy do not work and I have to repeat this step lot of time (I work on a server).

Can you please help me to figure out this problem?

Thanks

0 Kudos
1 Solution

Accepted Solutions
OwenEarley
Occasional Contributor III

If you just want to copy the shape of selected features in the ArcMap Python window then:

  • Add your two shapefiles to ArcMap and open the Python window.
  • Select the features you want to copy and enter the following python code - make sure to change the layer names to match your input and output:

inscursor = arcpy.da.InsertCursor("OutputShapes",("SHAPE@"))

with arcpy.da.SearchCursor("InputData", ["SHAPE@"]) as cursor:

    for row in cursor:

        inscursor.insertRow((row[0],))

For example:

copy-geom.png

This will copy just the geometry into the output shapefile.

Hope this helps.

Owen

Spatial XP

View solution in original post

0 Kudos
3 Replies
OwenEarley
Occasional Contributor III

If you just want to copy the shape of selected features in the ArcMap Python window then:

  • Add your two shapefiles to ArcMap and open the Python window.
  • Select the features you want to copy and enter the following python code - make sure to change the layer names to match your input and output:

inscursor = arcpy.da.InsertCursor("OutputShapes",("SHAPE@"))

with arcpy.da.SearchCursor("InputData", ["SHAPE@"]) as cursor:

    for row in cursor:

        inscursor.insertRow((row[0],))

For example:

copy-geom.png

This will copy just the geometry into the output shapefile.

Hope this helps.

Owen

Spatial XP

0 Kudos
SaidAkif
New Contributor III

Thanks Very much. I will try it and send a comment on this

0 Kudos
SaidAkif
New Contributor III

It work perfectly. Thanks a lot

0 Kudos