Select to view content in your preferred language

Change Detection in arcpy

371
0
02-11-2024 11:45 AM
Labels (3)
LorenaDaltro
New Contributor

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 :

--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) In [68]: Line 1: arcpy.sa.ChangeDetection(raster1, raster2, output_change_detection) AttributeError: module 'arcpy.sa' has no attribute 'ChangeDetection'
 
 Someone helps me ? with documentation or code about change detection?

 

 

 

 

 

 

0 Replies