AnsweredAssumed Answered

Batch Con statement Problem - ArcPython

Question asked by zia207 on Sep 24, 2019

I am trying to extract time series EVI values in a crop land raster layer (1 = cropland) using  Con statement in raster calculator, I am trying using below code, but it showed error. Any help appropriate 

 

try:

   import arcpy,arcinfo
   import sys
   import os

   if arcpy.CheckProduct("ArcInfo") == "Available":
      print "available"

   if arcpy.CheckExtension("Spatial") == "Available":
   arcpy.CheckOutExtension("Spatial")
      print "License is available"

   

   arcpy.env.workspace = r"H:/Bangladesh_Data/MODIS/MODIS_INDICES/YEAR_2000/CLIP_BD/EVI"
   rasterList = arcpy.ListRasters("*","TIF")
   for raster in rasterList:

      # ouput raster location
      outLoc = "H:\\Bangladesh_Data\\MODIS\\MODIS_INDICES\\YEAR_2000\\CROP_BD\\EVI\\"+raster

      # cropland raster 
      inRast= "H:\\Bangladesh_Data\\BD_Cropland\\bd_cropland_250.tif"  
   arcpy.gp.RasterCalculator_sa(Con(inRast == 1,raster), outLoc)

 

except:
   print "failed."
   print arcpy.GetMessages()

 

Outcomes