1

Below is my code. I'm having issues with this will work sometimes then other times it will not work.

# Import dependencies:
import arcpy
import glob, os
arcpy.CheckOutExtension('Spatial')
arcpy.env.overwriteOutput = True

# Define variables:
filepath = r'\'
folder = []
threshold = -19

os.chdir(filepath) 
for i in glob.glob('*.tif'):
    folder.append(i)    

# Loop through the folder:
ras = arcpy.Raster(i)
body = arcpy.sa.Con(ras < threshold, 1)
outfile = r'' + i[17:35] + '.shp' 
body_shp = arcpy.RasterToPolygon_conversion(body, outfile, "NO_SIMPLIFY")

closed as unclear what you're asking by Midavalo Apr 14 '17 at 21:11

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Welcome to GIS SE! As a new user please take the tour to learn about our focused Q&A format. Please tell us about the issues you are having with the code - you can edit your question to include detailed information about what happens when you run your code, and how it differs to what you expect. Include any error messages you encounter. Also give more details about what your code is supposed to do. – Midavalo Apr 14 '17 at 21:07
  • 1
    Your line filepath = r'\' will fail. You cannot have a single backslash '\' as a string variable - you need either a double backslash '\\' or a forward slash '/'. That said, it appears there should be a path here, like r'C:\Temp' – Midavalo Apr 14 '17 at 21:09
  • 1
    Also, you have a comment # Loop through the folder:, but you're not looping through any folder. You either need a new for loop, or indent some more lines inside your previous for loop. – Midavalo Apr 14 '17 at 21:12