Hi everyone, I am working on a project regarding PRO aimed at automating the analysis process for changes in LULC. I have four rasters, each containing 19 classes. My objective is to create four new rasters that represent the transitions between classes for each year within the analysis period (2019, 2020, 2021, and 2022). This involves categorical changes, where my rasters contain IDs while the class names are stored in the layer file.
import arcpy
# Defina o diretório onde os rasters estão localizados
arcpy.env.workspace = "Caminho_para_seu_diretório"
# Liste os rasters
raster_list = arcpy.ListRasters("*_cocoa")
# Verifique se há pelo menos dois rasters na lista
if len(raster_list) >= 2:
# Defina os rasters de entrada
raster1 = raster_list[-2] # Segundo raster mais recente
raster2 = raster_list[-1] # Raster mais recente
# Defina o nome do arquivo de saída
output_change_detection = "cocoa_change_detection.tif"
# Execute a ferramenta ZonalStatisticsAsTable
arcpy.sa.ZonalStatisticsAsTable(raster1, "VALUE", raster2, output_change_detection, "DATA", "MEAN")
print("Detecção de mudanças concluída.")
else:
print("Pelo menos dois rasters são necessários para executar a detecção de mudanças.")
but retorns the error :