2

Is there any way to convert polygons that do not have coordinates in the attribute table to a txt file with coordinates.

I will be using the txt file in a different software (not ArcGIS), so I need the txt file with polygon coordinates.

1
  • 1
    For getting better answers, could you add a couple of details: Do you wish to get coordinates of polygon vertices or polygon centroids? Are your polygons in a shapefile? Which version of ArcGIS are you using? And do you wish to perform this in ArcGIS only or you don't mind to install some open-source software, or to program a little?
    – nadya
    Commented Nov 13, 2012 at 2:06

2 Answers 2

5

The easiest way would be to use ogr2ogr from the GDAL package (an open source spatial conversions library) and convert your feature class to a text format such as GeoJSON (and the specification). I'd strongly recommend this method if possible, especially if you don't have much programming experience.

If you don't have access to this (can't install it, or your data is in SDE or another format which you can't access with ogr2ogr) then it's possible using the arcpy Python module to extract feature geometries using a SearchCursor (I'm assuming you're using ArcGIS 10, but this would also work with 10.1).

Depending on your polygons you have two potential methods in ArcGIS:

  • If you have simple polygons (no multipart, no holes) you can use geom.geo_interface to extract the vertices as a geojson string. For example:
shapefieldname = arcpy.Describe(dataset).ShapeFieldName

for row in arcpy.SearchCursor(dataset):
    print row.getValue(shapefieldname).__geo_interface__
  • Otherwise if the geometry is more complex take a look at this sample script from the ESRI help on Reading Geometries.
0
3

Assuming you want to use ArcGIS to convert the polygon features to a table, which will then be be used in different software, try the following:

  1. Open your feature attribute table
  2. Add Field > Type Double > Label "x"
  3. Right click on the new field name "x" and select "Calculate Geometry"
  4. Choose Property: "X coordinate of centroid" > OK

  5. Repeat steps 2 - 4 for the Y coordinates

enter image description here

Please note that these coordinates represent the centroid of the polygon features (i.e. the geometric center of the polygon)

To export the table:

  1. In the attribute table, select "Export..."
  2. Choose the file tab which opens a new window, select Save as Type: "Text File"
  3. Save

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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