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