I need to create the polygon Shape-file in python, by using given coordinates: [(0, 0), (0, ,000), (1,000, 0), and (1,000, 1,000)].
How can i create it, i tried some methods but they don't work ?
The gist of what you need is:
outFC = #path to shapefile, ending in .shp
coords = [[0.0, 0.0],[0.0, 1.0],[1.0, 1.0],[1.0, 0.0]]
arr = arcpy.Array([arcpy.Point(*coord) for coord in coords])
pn = arcpy.Polygon(arr)
(When I first wrote this reply there was a code snippet that has since been removed, which is unfortunate because it is easier for others to comment on code and it demonstrates previous efforts to solve the problem. Although my comments might not make sense to other readers, the OP should understand them.)
Reviewing ArcGIS Help for Create Feature Class (Data Management), especially the code samples, would be helpful. With the current approach you are taking, the Copy Features (Data Management) tool is more likely what you will need.
Yes i removed the code, because there was some bugs init, and i feel its better to remove it. Well thanks for the help. can you please elaborate the line 4, (*coord) ?
If you look at the Help for Point (arcpy), arcpy.point takes up to five optional arguments with the first two ordered arguments being X and Y coordinates. The coords list is a list of lists with the lists holding XY coordinate pairs. In Python, the asterisk or splat operator is used for Unpacking Argument Lists. Instead of passing each argument explicitly, I used the splat operator to unpack the XY coordinate pairs and pass them together for each point.
Following are three different ways to pass the same XY coordinates to arcpy.point:
coord = [1.0, 1.0]
#passing XY as indexed list elements
#passing XY as named local variables
X = coord
Y = coord
X, Y = coord
#passing XY using splat operator
Thanks for help
Retrieving data ...