Select to view content in your preferred language

Problem with running script outside of ArcMap (licensing, parameters)

2389
12
Jump to solution
10-02-2014 01:27 AM
LeonoreBehr
Deactivated User

Hello,

I have written a script which runs fine inside of ArcMap in the Python-Window but does not outside of ArcMap in PythonWin.

My intention for the last step was to delete all the files I created except of the Result txt-file.

But if I run the script in PythonWin there seems to be some problems with the license of Spatial Statistic or/and with the fparameters within the arcpy functions.

The script looks like this (sorry, the explanation parts and the file names are partly in german):

import os, arcpy

Pfad="C:/Users/behr/Desktop/DAC_MD/"

Pfad1="C:/Users/behr/Desktop/DAC_MD/Delete/"

PfadTxt="C:/Users/behr/Desktop/DAC_MD/01_MD_HH_klein/"

# Festlegen ob das Ergebnis Hydr. Höhen oder Salzgehalt ist

Sz="HH"

TextDateienListe = os.listdir(PfadTxt)

for Datei in TextDateienListe:

    #Datei=TextDateienListe[1]

    b = os.path.splitext(Datei)   

         # XY-Event Layer erstellen // Input: txt-Datei //Output: Layer mit Variable EventLayerName

    EventLayerName= b[0] + "_Layer"

    arcpy.MakeXYEventLayer_management(PfadTxt+Datei,"x","y",EventLayerName,"PROJCS['ETRS_1989_UTM_Zone_33N',GEOGCS['GCS_ETRS_1989',DATUM['D_ETRS_1989',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',15.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]];-5120900 -9998100 10000;-100000 10000;-100000 10000;0,001;0,001;0,001;IsHighPrecision","HH")

        # Kriging // Output: Raster rXXX

    arcpy.gp.Kriging_sa(EventLayerName,"HH",Pfad1+"r" + b[0],"Spherical 15,717080","15,7170800000001","VARIABLE 12","#") 

        # Hydrotopdatei kopieren zum späteren Einlesen der gemittelten Werte

    arcpy.CopyFeatures_management(Pfad+"HydrotMD.shp",Pfad1+"Hydrotop" + b[0]+".shp","#","0","0","0")

        #Zonale Statistiken: Mittelwerte bilden für Hydrotop und Raster und in Tabelle ausspucken

    arcpy.gp.ZonalStatisticsAsTable_sa(Pfad1+"Hydrotop" + b[0]+".shp","ID_COMTESS",Pfad1+"r" + b[0],Pfad1+ "t"+b[0],"DATA","MEAN")

     

        # Tabellenfeld per ID_COMTESS-Feld in die hydrotop-Datei integrieren

    arcpy.JoinField_management(Pfad1+"Hydrotop" + b[0]+".shp","ID_COMTESS",Pfad1+ "t"+b[0],"ID_COMTESS","MEAN")

        #Exportieren der ID mit dem dazugehörigen Mittelwert in eine Textdatei

    arcpy.ExportXYv_stats(Pfad1+"Hydrotop" + b[0]+".shp","ID_COMTESS;MEAN","SPACE",Pfad + "Results/01_MD_"+Sz+"_"+b[0],"ADD_FIELD_NAMES")

arcpy.CopyFeatures_management(Pfad+"HydrotMD.shp",Pfad1+"Hydrotop" + b[0]+".shp","#","0","0","0")

    #Zonale Statistiken: Mittelwerte bilden für Hydrotop und Raster und in Tabelle ausspucken
arcpy.gp.ZonalStatisticsAsTable_sa(Pfad1+"Hydrotop" + b[0]+".shp","ID_COMTESS",Pfad1+"r" + b[0],Pfad1+ "t"+b[0],"DATA","MEAN")
    # Tabellenfeld per ID_COMTESS-Feld in die hydrotop-Datei integrieren
arcpy.JoinField_management(Pfad1+"Hydrotop" + b[0]+".shp","ID_COMTESS",Pfad1+ "t"+b[0],"ID_COMTESS","MEAN")

    #Exportieren der ID mit dem dazugehörigen Mittelwert in eine Textdat
arcpy.ExportXYv_stats(Pfad1+"Hydrotop" + b[0]+".shp","ID_COMTESS;MEAN","SPACE",Pfad + "Results/01_MD_"+Sz+"_"+b[0],"ADD_FIELD_NAMES")

The errors occuring are:

1.

ExecuteError: Errors during execution . Parameters are invalid .

ERROR 000824: The tool is not licensed .

Error executing ( kriging ) .

So my question is: is it not possible to run spatial statistic stuff outside of arcmap because of the license?

And could the first problem be, that I cant't use the parameters like "HH" as the row-definition in the attribute table outside of ArcMap?

Thanks in advance!

Leonore

0 Kudos
12 Replies
JamesCrandall
MVP Alum

I didn't notice any code suggesting to perform SA checkout and I why I posted.  The OP was in English and a quick scan of the thread didn't show any solutions in any language -- but no, I don't speak German

If the user "behr" is not actually the account executing the code then I'd think there would be permission issues.

0 Kudos
LeonoreBehr
Deactivated User

It is not, that I need the data there, it is only: it was the most comfortable way so I can see what is going on.

The user "behr" is excecuting the code, but is not the admin on the PC. This could cause the problem, I think. But this problem doesn't really bother me anymore, I can delete the files by hand. Would only have been more comfortable....

But thanks a lot for trying to give me a solution and for the previous post!

0 Kudos
JamesCrandall
MVP Alum

The user "behr" is excecuting the code, but is not the admin on the PC

That is the likely culprit.

0 Kudos