[GIS] Converting polygon layer to *.txt files using ArcGIS Desktop

arcgis-desktopasciiconvertpolygon

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.

Best Answer

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.