This content has been marked as final. Show 1 reply
I have an Excel spreadsheet with 50, 4 corner coordinates. I need to create a shapefile from this that will show 50 Polygons. A step by step would be greatly appreciated!
You can read the coordinates directly from your spreadsheet in ArcGIS (provided there are no spaces or illegal characters in the sheet/field names, etc.). Or, if you like, you may optionally convert your Excel table, say directly to a scratch gdb or dbf table for further use in ArcGIS. The general procedure for converting your points to polygons using arcpy scripting methods (Python) provided with ArcGIS are as follows:
- set up a search cursor to 'read' the input table of coordinates line-by-line.
- set up an insert cursor on a new output fc to 'write' the output polygon features.
- loop on each line of the input table to create point objects, assigning each set of coordinates to a 'reusable' point object.
- load each point object into an array object (also 'reusable') that will define the polygon perimeter.
- for each new polygon to be created, load the array object into a new geometry.
- load the new geometry into a new row in the output fc.
As an alternative, particularly as practice with Python, there is an example script online at (the 1st example):
Provided you convert to a similarly formatted text file (which you can easily do from Excel), you can follow it to a tee. Only 3 input parameters are required at the beginning for your input text file (infile), feature class name to create (fcname), and fc 'clone' from which pattern the new fc as (template):
infile = arcpy.GetParameterAsText(0)
fcname = arcpy.GetParameterAsText(1)
template = arcpy.GetParameterAsText(2)
You can hard-code these if you like, for example:
infile = r'C:\directoryPathYouHave\yourTxtFileName.txt'
fcname = 'fcName'
template = r'C:\directoryPathYouHave\yourGDB.gdb\fcTemplate'
So your sets of 4-corner coordinates would be represented in the txt file by IDs 1, 2, 3,...50. If that makes sense, and you wish to further adapt this script to accept input directly from Excel, that can be done too. Hope that helps.