1

I am trying to extract projection details of vector files (it might be a tab or shp file) in multiple subfolders using arcpy's describe.SpatialReference. If i run this code, i am getting this error. I've just changed the code given here from list feature_class to list files. Since i am very much new to arcpy, don't know what went wrong

"AttributeError: DescribeData: Method spatialReference does not exist "

import arcpy
import os

arcpy.env.workspace = "D:/QAQC"
feature_classes = arcpy.ListFiles()

for csv_file in arcpy.ListFiles("*.tab"):
spatial_ref = arcpy.Describe(fc).spatialReference
  if spatial_ref.name == "Unknown":
     print("{0} has an unknown spatial reference".format(fc))
  else:
     print("{0} : {1}".format(csv_file, spatial_ref.name))

Edit: I've run the same code for shp and it's working perfectly.

  • TAB is a MapINFO format not an Esri format. Unless you're using inter operablility extension you wont be able to read them. – Michael Stimson Apr 29 '16 at 2:32
  • But if i use List.FeatureClasses for an individual tab file, it's working. – joseph_k Apr 29 '16 at 2:34
  • 1
    Perhaps you do have that extension.. or support for MapINFO is new in 10.3, consider a TAB file to be a feature dataset but without spatial reference, you need to go one level down into the feature class to get the spatial reference. Set your workspace to the TAB then use ListFeatureClasses to get each component then describe these. – Michael Stimson Apr 29 '16 at 2:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.