1

1= Is the polygon that I want to replicate. 2= the points represents the location where the replicated polygons should be.]1 will stay [1]I have two shapefiles, one is a polygon and the other is points. I would like to create a new shapefile which has the shape of the polygon in all the places that there is points. I would like to replicate the polygon under the points.

1= the polygon that I want to replicate. 2= the points represents the location where the replicated polygons should be (one polygon per point).

closed as unclear what you're asking by Jochen Schwarze, whyzar, Mark Ireland, Dan C, neogeomat Jan 31 at 17:38

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Hi, just to be clear, are you trying to select polygons that contain points and save the selected polygons in a new file? – Trevor J. Smith Jan 29 at 17:50
  • 1
    Welcome to GIS SE! As a new user, please be sure to take the short tour to learn about this site's focused Q&A format. Then, I suggest you edit your question to include a few screenshots illustrating what you want to accomplish. – Andy Jan 29 at 18:32
  • 2
    You appear to have two discrete logins. Please use this link to merge the accounts. – Vince Jan 31 at 1:15
  • Hi Ana, I assume this is ArcGIS, and that in some places points lie on/within polygons. If so, "Select by Location" on the polygons using the points. Then Export the polygons to a new layer; by default, only the selected ones will be exported. The concept is the same in other GIS, like QGIS. – Paulo Raposo Jan 31 at 5:08
1

You can use arcpy and the da.Search/Update/InsertCursors:

import arcpy

points = 'placehere' #Change
polygon = 'copyme' #Change. Must only contain one polygon which is used as template. This feature class will modified so backup/make a copy if you want to keep one unchanged.

coordinates = [i[0] for i in arcpy.da.SearchCursor(points,'SHAPE@XY')] #List point coordinates
fieldnames = [f.name for f in arcpy.ListFields(polygon) if not (f.type.startswith('OID') or f.name.startswith('SH'))] #List polygon fields
polytemplate = [i for i in arcpy.da.SearchCursor(polygon,fieldnames+['SHAPE@'])][0] #Create a polygon template

#Insert pointcount-1 number of polygons
icur = arcpy.da.InsertCursor(polygon, fieldnames+['SHAPE@'])
for coord in coordinates[1:]: 
    icur.insertRow(polytemplate)
del(icur)

#Update their centroid coordinates to match the Points (I dont Think this is possible with the insertcursor, if im wrong please comment.
coords = iter(coordinates)
with arcpy.da.UpdateCursor(polygon,'SHAPE@XY') as cursor:
    for row in cursor:
        try:
            row[0] = next(coords)
            cursor.updateRow(row)
        except StopIteration:
            break

Before: enter image description here

After: enter image description here

  • Hi Bera! This was exactly what I needed! thank you! I have a new question about the same situation. After replicating the polygons, how can I rotate them according to the direction of the points? – Ana Beatriz Freitas Jan 31 at 12:17
  • @AnaBeatrizFreitas Nice! Please accept my answer with the checkbox. That is a new question and a bit more complicated. Take a look at: Rotating polygons by value from attribute table using ArcPy?. Spatial join the rotation attribute from the Points to the polygons. – BERA Jan 31 at 12:26
  • I'm trying to use the script that you suggest n this post "Rotating polygons...", but there is an error that I can not understand. "Runtime error Traceback (most recent call last): File "<string>", line 20, in <module> TypeError: 'NoneType' object is not iterable" – Ana Beatriz Freitas Jan 31 at 14:13
  • 1
    @AnaBeatrizFreitas I Think you should post a new question and include the code you have tried and the error message. – BERA Jan 31 at 14:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.