POST
|
Hello, I am running a script where in the first step I create a xy-Event-Layer out of txt-files. I am loading like 2000 files one after another out of one folder. Now the process works fine, only it gets slower and slower. After 8 hours it needs like 4 minutes for one file, while in the beginning it finished 6 files in one minute. My Question is: Could it be that ArcGIS is saving something like an image of the XY-Eventlayers in temp-files somewhere so that my RAM can't work anymore in the end? The thing is, if I kill the script, turn the PC off and on again and start again, it works as fast as in the beginning. If I only delete the files in the "delete"folder, (which I created for the output of line 31-38 which appears during the process) and in the "normal" temp-folder, it doesn't get better. Thanks in advance for any help! The script looks like this:
import os, arcpy
Pfad="C:/Users/Lolaley/Desktop/DAC_MD/"
Pfad1="C:/Users/Lolaley/Desktop/DAC_MD/Delete/"
PfadTxt="C:/Users/Lolaley/Desktop/DAC_MD/01_MD_HH/"
# Festlegen ob das Ergebnis Hydr. Höhen oder Salzgehalt ist
Sz="HH"
arcpy.CheckOutExtension("Spatial")
TextDateienListe = os.listdir(PfadTxt)
import re
def k(s):
return [w.isdigit() and int(w) or w for w in re.split(r'(\d+)', s)]
TextDateienListe = sorted(TextDateienListe, key=k)
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",Sz)
# Kriging // Output: Raster rXXX
arcpy.gp.Kriging_sa(EventLayerName,Sz,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]+".txt","#")
arcpy.CheckInExtension("Spatial")
... View more
10-09-2014
06:49 AM
|
0
|
1
|
978
|
POST
|
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!
... View more
10-08-2014
02:44 AM
|
0
|
1
|
162
|
POST
|
OK, dann werde ich das halt einfach per Hand löschen müssen. Danke für die Lösungshilfe!
... View more
10-02-2014
02:19 AM
|
0
|
1
|
686
|
POST
|
Hallo Johannes, vielen Dank, das war die Lösung! Doch so einfach eine Frage habe ich noch: Ich wollte unten jetzt einfach noch folgendes einfügen: #Löschen der unnötigen Files for filename in os.listdir(Pfad+ "Delete/"): os.remove(os.path.join(Pfad+ "Delete/", filename)) um damit die Daten aus dem Delete-Ordner, in dem ich alle Zwischenschritte abgespeichert habe, bequem zu löschen. Da erscheint aber folgender Error: WindowsError: [Error 5] Zugriff verweigert: 'C:/Users/behr/Desktop/DAC_MD/Delete/info' Liegt das dann an den Windows-Rechten? Kann ich die vielleicht irgendwie umgehen? Vielen Dank schonmal, Leonore
... View more
10-02-2014
01:53 AM
|
0
|
3
|
686
|
POST
|
Sorry, it seems I couldn't load the file exactly: The lines 42 till 80 are indented, too, in the original script.
... View more
10-02-2014
01:29 AM
|
0
|
0
|
686
|
POST
|
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
... View more
10-02-2014
01:27 AM
|
0
|
12
|
1422
|
POST
|
Hello Mark, Thanks a lot! Actually this was the whole problem. And thank you, too, for the link to the 'tip thread' - think it will help solving some problems in my project occuring in the future. (But I think I will skip the google translator - it does other mistakes than I do, but just as much 🙂 ) Leonore
... View more
03-11-2014
12:31 AM
|
0
|
0
|
26448
|
POST
|
Hi, I'm new to Archydro and have installed Archydro in ArcMap 10.1. Everytime I try to run one of the applications like calculating slope or flowdirection out of my .grd or .tif the Error "HRESULT E_FAIL has been returned from a call to a COM component" (or in my case in German: "Beim Aufruf einer COM-Komponente wurde ein HRESULT E_FAIL-Fehler zurückgegeben.") appears. I have a huge DEM to work with and wanted to calculate the Catchment area. Does anyone know what the cuase of this error could be? I already shortened the workpath and the filename but this didn't help. Thanks in advance!!
... View more
03-10-2014
02:35 AM
|
0
|
15
|
89948
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|