+ Reply to Thread
Results 1 to 2 of 2

Thread: How do I create a polygon shapefile from an Excel spreadsheet?

  1. #1

    Join Date
    Oct 2012
    Posts
    1
    Points
    0
    Answers Provided
    0


    0

    Default How do I create a polygon shapefile from an Excel spreadsheet?

    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!

  2. #2
    T. Wayne Whitley

    Join Date
    Apr 2010
    Posts
    1,026
    Points
    842
    Answers Provided
    118


    0

    Default Re: How do I create a polygon shapefile from an Excel spreadsheet?

    Quote Originally Posted by edcisler View Post
    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):
    http://help.arcgis.com/en/arcgisdesk...0000001v000000

    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.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts