dfechter

CostPath: All cells in grid have NODATA value. VAT will not be built.

Discussion created by dfechter on Jul 23, 2013
Latest reply on Jul 24, 2013 by dfechter
Hi guys,
I have a huge problem running my python-script outside of ArcGIS. I'm trying to calculate a series of CostPath analysis and getting errors I can't figure out. Already rzufelt gave me some ideas, but they lead to other error messages. So I open a new thread, since the orignal one might be missleading in its title.

This is the rror message I get:

All cells in grid c:\dokume~1\admin\lokale~1\temp\t_t52108 have NODATA value. VAT will not be built.
Traceback (most recent call last):
  File "E:\My Dropbox\Diss\Python Workspace\GIS Tutorial\src\gis_proj.py", line 229, in <module>
    outCostPathFrankreich = CostPath("E:/CORINE/CP_Paper3/RunP/FPFrankreich_lyr.lyr", outCostDist, outBkLinkRaster, "BEST_SINGLE", "CID")
  File "C:\Programme\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Functions.py", line 693, in CostPath
    destination_field)
  File "C:\Programme\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Utils.py", line 47, in swapper
    result = wrapper(*args, **kwargs)
  File "C:\Programme\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Functions.py", line 686, in wrapper
    destination_field)
  File "C:\Programme\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 474, in <lambda>
    return lambda *args: val(*gp_fixargs(args))
arcgisscripting.ExecuteError: ERROR 010045: COSTPATH: The number of FROM cells is 0.
ERROR 010067: Error in executing grid expression.
Failed to execute (CostPath).

The corresponding code looks like this (I apologize in advance, since my naming the the variables is a bit weird):

import sys
sys.path.append("C:/Programme/ArcGIS/Desktop10.0/arcpy/arcpy")

import random
import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True

arcpy.CheckOutExtension("Spatial")

# Read Raster 
infor = Raster("E:/CORINE/CP_Paper3/RunP/data.gdb/CORINE_Forest_Raster_Aggregate")
inpas = Raster("E:/CORINE/CP_Paper3/RunP/data.gdb/CORINE_Pasture_Raster_Aggregate")
inwet = Raster("E:/CORINE/CP_Paper3/RunP/data.gdb/CORINE_Wetlands_Buffer_Raster_Aggregate")
inroa = Raster("E:/CORINE/CP_Paper3/RunP/data.gdb/LDRoadsproj")
city = Raster("E:/CORINE/CP_Paper3/RunP/data.gdb/CORINE_City_Rec")
water = Raster("E:/CORINE/CP_Paper3/RunP/data.gdb/CORINE_Waterbodies_Rec")

#Read CostDistance analysis data
insourcedata = "E:/CORINE/CP_Paper3/RunP/data.gdb/WG_lyr_lyr"
#insourcedata = arcpy.MakeFeatureLayer_management("E:/CORINE/CP_Paper3/RunP/WG.shp", "E:/CORINE/CP_Paper3/RunP/WG_lyr" )

ZielVogesen = "E:/CORINE/CP_Paper3/RunP/data.gdb/VogPointBuffer_lyr_lyr"
ZielFrankreich = "E:/CORINE/CP_Paper3/RunP/data.gdb/FrancePointBuffer_lyr_lyr"
ZielItalien = "E:/CORINE/CP_Paper3/RunP/data.gdb/ItalPointBuffer_lyr_lyr"
ZielSchweiz = "E:/CORINE/CP_Paper3/RunP/data.gdb/SchweizPointBuffer_lyr_lyr"

PunktFrankreich = Raster("E:/CORINE/CP_Paper3/RunP/data.gdb/FPRaster")
PunktItalien = Raster("E:/CORINE/CP_Paper3/RunP/data.gdb/IPRaster")
PunktSchweiz = Raster("E:/CORINE/CP_Paper3/RunP/data.gdb/SPRaster")
PunktVogesen = Raster("E:/CORINE/CP_Paper3/RunP/data.gdb/VPRaster")

#Determine No of runs (I need to make something around 10.000 runs at the end)
numberofruns = 100

#Create csv for storing randomly selected values
try:
    # This will create a new file or **overwrite an existing file**.
    f = open("E:/CORINE/CP_Paper3/RunP/laufRunPen.csv", "w")
    try:
        f.write("Lauf Nummer; Intercept; Forest; Pastures; Wetlands; Roads; Gruenbruecke; Wirtschaftsweg; Kreisstrasse; Schnellstrasse; Autobahn; Tunnel; Bach; Fluss; Eisenbahn;\n") 
               
    finally:
        f.close()
except IOError:
    pass

#Create csv for storing CostDistance values
try:
    # This will create a new file or **overwrite an existing file**.
    f = open("E:/CORINE/CP_Paper3/RunP/CDWerte_der_Laeufe.csv", "w")
    try:
        f.write("Lauf Nummer; Frankreich; Italien; Schweiz; Vogesen\n") 
               
    finally:
        f.close()
except IOError:
    pass

#Create Featureclass for storing the different CostPath results
arcpy.CreateFeatureclass_management("E:/CORINE/CP_Paper3/RunP/", "CPFrankreich.shp", "POLYLINE", "E:/CORINE/CP_Paper3/RunP/CPPolyFrankreich_dissolve.shp", "DISABLED", "DISABLED", "E:/CORINE/CP_Paper3/RunP/data.gdb/corinepoly_clip")
arcpy.CreateFeatureclass_management("E:/CORINE/CP_Paper3/RunP/", "CPItalien.shp", "POLYLINE", "E:/CORINE/CP_Paper3/RunP/CPPolyFrankreich_dissolve.shp", "DISABLED", "DISABLED", "E:/CORINE/CP_Paper3/RunP/data.gdb/corinepoly_clip")
arcpy.CreateFeatureclass_management("E:/CORINE/CP_Paper3/RunP/", "CPSchweiz.shp", "POLYLINE", "E:/CORINE/CP_Paper3/RunP/CPPolyFrankreich_dissolve.shp", "DISABLED", "DISABLED", "E:/CORINE/CP_Paper3/RunP/data.gdb/corinepoly_clip")
arcpy.CreateFeatureclass_management("E:/CORINE/CP_Paper3/RunP/", "CPVogesen.shp", "POLYLINE", "E:/CORINE/CP_Paper3/RunP/CPPolyFrankreich_dissolve.shp", "DISABLED", "DISABLED", "E:/CORINE/CP_Paper3/RunP/data.gdb/corinepoly_clip")

#Counter for while loop
rnumber = 1

print "No. of runs which will be calculated: " +str(numberofruns)

while rnumber < (numberofruns+1):
    
    print "Durchlauf Nr.: " + str(rnumber)
    
    #Raster with crossing values
    quer = Raster("E:/CORINE/CP_Paper3/RunP/data.gdb/querausw")
    
    #Determine random values for the variables
    rin = random.normalvariate(-16.9479, 3.08)
    rfo = random.normalvariate(0.9425, 0.038)
    rpa = random.normalvariate(0.4744, 0.075)
    rwe = random.normalvariate(0.6794, 0.126)
    rro = random.normalvariate(-19.5362, 9.643)
    
    rqgre = max(min(random.normalvariate(0.95, 0.0125), 1.0),0.0)
    rqwir = max(min(random.normalvariate(0.75, 0.0625), 1.0),0.0)
    rqkre = max(min(random.normalvariate(0.65, 0.0875), 1.0),0.0)
    rqsch = max(min(random.normalvariate(0.25, 0.1875), 1.0),0.0)
    rqaut = max(min(random.normalvariate(0.1, 0.225), 1.0),0.0)
    rqtun = max(min(random.normalvariate(0.95, 0.0125), 1.0),0.0)
    rqbac = max(min(random.normalvariate(0.9, 0.025),1.0),0.0)
    rqflu = max(min(random.normalvariate(0.9, 0.025),1.0),0.0)
    rqeis = max(min(random.normalvariate(0.85, 0.0375),1.0),0.0)
    
    rqgreint = int(rqgre*10000)
    rqwirint = int(rqwir*10000)
    rqkreint = int(rqkre*10000)
    rqschint = int(rqsch*10000)
    rqautint = int(rqaut*10000)
    rqtunint = int(rqtun*10000)
    rqbacint = int(rqbac*10000)
    rqfluint = int(rqflu*10000)
    rqeisint = int(rqeis*10000)
    


I need to divide this in two posts, its getting too long :(

Outcomes