AnswerBun.com

Zonal statistics error in arcpy

Geographic Information Systems Asked by Charlera on August 18, 2020

I’m trying to get the zonal statistics output (mean), do some operations and add to my main archive the output value. I wrote this code, but it’s not running, the error message is:

Traceback (most recent call last):
  File "Z:4 - TempCharlesNDVI_tempoNDVI_py3.tbx#Script3_NDVIpy3.py", line 21, in <module>
  File "c:program filesarcgisproResourcesarcpyarcpysaFunctions.py", line 6328, in ZonalStatistics
    ignore_nodata)
  File "c:program filesarcgisproResourcesarcpyarcpysaUtils.py", line 53, in swapper
    result = wrapper(*args, **kwargs)
  File "c:program filesarcgisproResourcesarcpyarcpysaFunctions.py", line 6321, in Wrapper
    ignore_nodata)
  File "c:program filesarcgisproResourcesarcpyarcpygeoprocessing_base.py", line 506, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Object: Error in executing tool
Failed to execute (Script3).

import arcpy
import os
import datetime
from arcpy import env
from arcpy.sa import *

#Declarar as variáveis

arcpy.env.workspace = 'Z:\04 - Temp\Charles\NDVI_tempo\NAL_PL'
fcs = arcpy.ListFeatureClasses()
rasters = arcpy.ListRasters("test*", "All")
fc = 'Z:\04 - Temp\Charles\NDVI_tempo\NAL_PL\MA02ASEZ3S'
arcpy.CheckOutExtension("Spatial")

for tiff in rasters:
#Zonal statistics
    Zonaltif = ZonalStatistics(fc, ["ID_TALHAO"], tiff, "MEAN")
    Zonaltif.save('Z:\04 - Temp\Charles\NDVI_tempo\NAL_PL\teste')
    Zonalper = Times (Zonaltif, 100)
    Zonalint = Int (Zonalper)
    RasterToPolygon_conversion (Zonalint, Zonalpoly, "SIMPLIFY", "VALUE")
    Intersect_analysis ([Zonalpoly, fc], 'Z:\04 - Temp\Charles\NDVI_tempo\NAL_PL\teste\intertif', "ALL", "", "")

What am I doing wrong?

One Answer

Deleting spaces in output file directory worked in my case. Thanks!

Answered by Alex on August 18, 2020

Add your own answers!

Related Questions

Converting polygon to line with neighbor info using QGIS?

0  Asked on July 7, 2021 by radek-nakielski

   

Can catalog_apply output a LAScatalog?

1  Asked on July 6, 2021 by kah574

     

Buffer around suburb lines

0  Asked on July 6, 2021

     

Raster to GeoTIFF file conversion problem

0  Asked on July 6, 2021

   

How to write sderaster commands

1  Asked on July 6, 2021

 

OpenLayers print preview

0  Asked on July 6, 2021 by r-kut

   

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir