1

In the below script the processed file will be added to the table of content in ArcGIS, since my data is too long it cause the program to be closed due to opening too many files, how I can run the script without opening the processed file in ArcGIS.

import  arcpy
ws = arcpy.env.workspace = r'D:\BRB Snow Cover\Sample\Terra'
Terra_Rasters = arcpy.ListRasters("MOD*")
matches = 1
for item1 in Terra_Rasters:
    for item2 in Terra_Rasters:
        item1_num = int(item1[31:38])
        item2_num = int(item2[31:38])
        if (item2_num - 1) == item1_num:
            print item1
            print item2
            print "Match"
            output = "D:\\BRB Snow Cover\\Sample\\output1""\\" + str(item2) + '.tif'
            arcpy.gp.Con_sa(item2, item1, output, item2, "\"Value\" =8")
        else:
            print "No"
            matches = matches + 1
  • 1
    Run it in ArcCatalog or from a python IDE like PyWin. What are you trying to do with arcpy.gp.Con_sa? Your condition expression doesn't look right; you could try arcpy.sa.Con(parameters....).save(output). BTW have you checked and activated spatial analyst extension? It appears your iterating the same file list against itself, that definitely doesn't look right. – Michael Stimson Sep 19 '19 at 6:34
  • With condition I am trying to replace the cloud pixel with non-cloud pixels in the raster file and the iteration is the same list of file but different days. I have pycharm but the arcpy isn't working on the pycharm. I couldn't solve the problem. – Wahid Hussainzada Sep 19 '19 at 7:26
3

Update your environmental settings so that outputs aren't added to your map.

arcpy.env.addOutputsToMap = False
  • Thank you it works and now it take less time on my PC! – Wahid Hussainzada Sep 20 '19 at 1:47

Your Answer

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

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