1

I wrote the script:

import arcpy
if arcpy.CheckExtension("Spatial")=="Available":
    arcpy.CheckOutExtension("Spatial")
    print("Spatial")

from arcpy import env
from arcpy.sa import *
env.workspace = "D:\Semestr 2 MGR\GeoinformatykaB\Cwiczenia\C07\DaneSkryptGISv02\Dane\Orto"
arcpy.gp.ZonalStatisticsAsTable_sa("punkt","OBJECTID","CentrumGdanska.tif","C:/Users/ilona/Documents/ArcGIS/Default.gdb/ZonalSt_punkt2","DATA","MAXIMUM")

arcpy.CheckInExtension("Spatial")
print "end"

I have a problem. This script is failed. This is error:

ERROR 000824: The tool is not licensed.
Failed to execute (ZonalStatisticsAsTable).

Could anyone check if it works?

The content of the task:

Create a script to accumulate values from the raster. The tool comes with:

  • raster
  • the point from which the zone will rise
  • barrier value of the maximum sum of values obtained from raster cells.
  • 1
    Your script is quite odd. Of what value is checking out a seat of Spatial Analyst, then checking it in again? You need to make a checkout/check-in sandwich, with your SA functions inside. – Vince Jan 11 at 16:33
  • I check for value: [link]( drive.google.com/open?id=1HLB8CZEyyKdl19zrzdMqvvUwPO5DSJY7). I changed the order in the script of values: arcpy.CheckInExtension ("Spatial") – Ilona Jan 11 at 20:04
  • 1
    When you run the code do you see the word "Spatial" get printed in the command line window to prove that the extension was checked out? – Hornbydd Jan 11 at 20:14
  • Yes, "Spatial" is printed. LInk – Ilona Jan 11 at 20:25
  • @user2856 I changed what you wrote and printed the word "End" – Ilona Jan 11 at 20:44
1

Use ZonalStatisticsAsTable instead of arcpy.gp.ZonalStatisticsAsTable_sa.

The ZonalStatisticsAsTable function is part of the arcpy.sa package and was imported with from arcpy.sa import *

Also use env.workspace = r"D:\etc... i.e a raw string r"" or double (escaped) backslashes or single forward slashes instead of single (unescaped) backslashes.

| improve this answer | |

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