Yo soy el procesamiento por lotes de una gran cantidad de las funciones de la distancia (~50,000) el uso de ArcGIS 9.3. En esta versión, el uso de spatial analyst funciones, parece ser el caso de que los usuarios no se pueden paralelizar procesos a través de núcleos, o escribir a in_memory en lugar del disco duro de pasos intermedios, y hay una fuga de memoria inherente en el programa que causa el procesamiento a ser más lenta varios bucles. He visto un post del foro que muestra una cruda solución para la pérdida de memoria que se apaga la recolección de basura, pero que por sí sola probablemente no va a ayudar un montón. Ahora estoy mirando los tiempos de procesamiento en el orden de un par de semanas en el equipo que estoy usando para esto.
¿Alguien sabe de alguna fiable work-arounds que me permitiría escribir SA de salida a in_memory, paralelizar procesos, o en alguna otra forma de aumentar significativamente la velocidad de procesamiento? Estoy abierto a que con ERDAS si tengo que.
Secuencia de comandos:
# Import system modules
import sys, string, os, arcgisscripting, time, shutil
# Create the Geoprocessor object
gp = arcgisscripting.create(9.3)
# Allow overwrites
gp.overwriteoutput = 1
# ----------------------------------------------------------
# Set changeable model parameters
# ----------------------------------------------------------
cell_sz = 90.04245658
Max_oid = 1 # Should be = 54567 for irrigated agriculture, in province sources - Range function starts at 0 and stops 1 before number in range - so this number should be = number of records in shapefile
Win_sz = 3100 # This is the minimum possible size, and should make it so that even the largest k results in values = 0.001 or less at boundary
# Create a folder for this set of runs, designated by the current time, then copy the script being run to the folder and time stamp it
t = time.localtime()
timeholder = str(t[0]) + '_' + str(t[1]) + '_' + str(t[2]) + '_' + str(t[3]) + str(t[4]) + '_' + str(t[5])
folder_time_name = "M:\\Jess_GIS_NIDR\\" + timeholder
os.mkdir(folder_time_name)
filename=sys._getframe().f_code.co_filename
shutil.copyfile(filename, folder_time_name + '\\this_script_executed_' + timeholder + '.py') #shutil
# Check out any necessary licenses
gp.CheckOutExtension("spatial")
cell_sz_str = str(cell_sz) + " METERS"
gp.cellSize = cell_sz
# Set up loop to go through the data set, iteratively select cells out, and processs distance calculations
for i in range(Max_oid):
pt = i
print "Processing point number " + str(pt)
# Load prepped dataset containing this point
irragg = "M:\\Jess_GIS_NIDR\\Pts_irragg\\pt_int_" + str(pt) + ".shp"
# Publish output to common folders - may add additional dists_proc style folders
Dists_raw = "in_memory\\dists_raw"
# Define local variables (files only associated with processing this source cell)
DEM = "M:\\Jess_GIS_NIDR\\InputRasters_Globcover_Hydrosheds\\HydroSHEDS\\dem"
Dir_hydro = "M:\\Jess_GIS_NIDR\\InputRasters_Globcover_Hydrosheds\\HydroSHEDS\\drain_dir"
Dists_fin = folder_time_name + "\\Dists\\Dists_fin.shp"
# Identify and set processing extent
y = []
x = []
cur = gp.SearchCursor(irragg)
row = cur.Next()
while row:
extent = row.Shape.Extent
y.append(extent.ymin)
x.append(extent.xmin)
row = cur.Next()
del row
del cur
ypt = y.pop(0)
xpt = x.pop(0)
def incmax(a): return (a + Win_sz)
def incmin(b): return (b - Win_sz)
ymin = incmin(ypt)
ymax = incmax(ypt)
xmin = incmin(xpt)
xmax = incmax(xpt)
del y
del x
gp.extent = "%f %f %f %f" % (xmin, ymin, xmax, ymax)
# Path-distance function
gp.PathDistance_sa(irragg, Dists_raw, "", DEM, Dir_hydro, "FORWARD 0.01 0.5", "", "", "", "")
# Convert distance results to permanent shape file
gp.RasterToPoint_conversion(Dists_raw, Dists_fin, "VALUE")
# Further processing of original distance raster to get at first order ideas of distance
# ---------------------------------------------------------------------------------------
# Crudely correct for the fact that the original land-use data was originally at a coarser resolution than this dataset
gp.AddField_management(Dists_fin, "Dcorr", "DOUBLE", "", "", "", "", "NULLABLE", "", "")
gp.CalculateField_management(Dists_fin, "Dcorr", "[RASTERVALU] - 90.04245658", "", "")
# First order distance function
gp.AddField_management(Dists_fin, "Dist_k", "DOUBLE", "", "", "", "", "NULLABLE", "", "")
gp.CalculateField_management(Dists_fin, "Dist_k", "Exp([Dcorr]*-0.00231)", "", "")