Dear all,
I have GIS data in csv file format that describes polygons (administrative districts). There are four values: 1. Longitude 2. Latitude 3. Unique identifier 4. Text name of the administrative districts.
A polygon then is described in the following manner: Note the first vertex point is repeated at the end to indicate the extent of the polygon before a new polygon is described.
Description | ID | Longitude | Latitude |
Adams (Pob.) | 12801001 | 120.8646 | 18.4333 |
Adams (Pob.) | 12801001 | 120.8665 | 18.4391 |
Adams (Pob.) | 12801001 | 120.8677 | 18.4424 |
Adams (Pob.) | 12801001 | 120.8685 | 18.449301 |
Adams (Pob.) | 12801001 | 120.8691 | 18.4515 |
Adams (Pob.) | 12801001 | 120.8708 | 18.4554 |
Adams (Pob.) | 12801001 | 120.872 | 18.459 |
Adams (Pob.) | 12801001 | 120.8735 | 18.462999 |
Adams (Pob.) | 12801001 | 120.8646 | 18.4333 |
Can someone tell me, if it is possible, how to import these data into ArcGIS and create a polygon shape file? My ultimate objective is to calculate the area of district.
Much appreciated!
Hmmm, shapefiles, CSV - I bet Dan Patterson has a solution. One caveat - it may involve Python
Chris Donohue, GISP
@Omar Mcdoom I think the answer to your question can be found here: Format for CSV to import as polygons (rectangles)?
This ESRI article suggests several methods:
43993 - Convert a point feature class to a polygon feature class
Note that some of the processes require higher level licenses and one solution requires a third-party software (ET Geowizards).
Chris Donohue, GISP
Here's a starting point using Python. This only reads your csv and outputs a polygon for all the points. It gets a little more complicated to create separate polygons for each ID, to write out all the attributes, etc.
>>> import csv # import csv library ... polys = [] # list to hold polygon geometry ... with open(r'C:\junk\pointcsv.csv', 'rb') as csvFile: # open csv file ... csvFile.readline() # skip header ... csvReader = csv.reader(csvFile) # create csv reader ... polyPoints = arcpy.Array() # array to hold points ... for row in csvReader: # read csv ... polyPoints.append(arcpy.Point(row[2],row[3])) # create point and add to array ... polys.append(arcpy.Polygon(polyPoints,arcpy.SpatialReference(4326))) # create polygon and add to list ... arcpy.CopyFeatures_management(polys, r'in_memory\polys') # write out polygons
Unless you're committed to learning Python, your best bet is probably to add your csv as points, convert to line, then convert to polygon.
Thank you for the suggestions. I am not a Python and find it easier to use the built-in windows-driven tools.
When I use the "Points to Line" feature, what do I specify for "Line field" "Sort field" and "Close line" boxes? If I enter nothing, I then receive the error message when I try to draw the line layer/shapefile stating "a lock cannot be acquired".
What am I missing here? Thank you!
Line field is the field controlling the line IDs (tells the tool when to end the current line and move to the next line), Sort field sorts the records from first to last (if they aren't in the correct order already) and Close line forces the lines closed (if they aren't already).