Select to view content in your preferred language

CreateRandomPoints_management creates empty feature class

2460
10
07-22-2013 07:07 AM
DominikFechter
Emerging Contributor
Hi guys,
I'm totally lost and on the verge of a mental breakdown. I'm trying to write a script for an automatic CostPath analysis and I'm getting very weird results and errors. Basicly what I want is this:

I'm creating a CostDistance Raster dataset and the backlink set by multiplying different Raster Datasets with randomly generated numbers and using a polygon-feature class as the starting point. so far so good. Then I create four random points, constraint by four polygones to act as the destination. When I start the CostPath analysis, I get this error:

Traceback (most recent call last):
  File "E:\My Dropbox\Diss\Python Workspace\GIS Tutorial\src\test_rand.py", line 216, in <module>
    outCostPathFrankreich = CostPath(PFrankreich, outCostDist, outBkLinkRaster, "BEST_SINGLE", "FID")
  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.

Funny thing: When I look in my folder, there are four point features created, each with a point within my constraining feature class. So the points exist, but is does not work...

here are some code snippets that may help to understand the mess I made:
I dont post all the code to keep it small, if you need it, then please ask!


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")


#load constraining feature
ZielFrankreich = "E:/CORINE/CP_Paper3/Auswertung/basedata.gdb/FrancePointBuffer"

#create the random point
PFrankreich= arcpy.CreateRandomPoints_management("E:/CORINE/CP_Paper3/Auswertung", "randFrankreich", ZielFrankreich, "", 1)

#CostPath analysis, outCostDist, outBkLinkRaster have already been created, but to keep the codeblock as small as possible i dondt post it 
outCostPathFrankreich = CostPath(PFrankreich, outCostDist, outBkLinkRaster, "BEST_SINGLE", "FID")



If anyone has any idea that would be great. As I said, I'm so completly frustrated.... If you need any additional information, please ask.

Cheers, thanks a lot in advance,

Dominik
Tags (2)
0 Kudos
10 Replies
DominikFechter
Emerging Contributor
I'm using Version 10.0. In the exported Python script the command for the costdistance for example was arcpy.gp.CostDistance_sa()
I think in ArcGIS 10.0 the command is arcpy.CostDistance() or arcpy.sa.CostDistance()

Also the command in ArcGIS 9.3 had 5 parameters, instead of 4 in ArcGIS 10.0. Still the arcpy.gp.CostDistance_sa() works in Version 10.0... Strange, but at this point I just accept the wonders that are ArcGIS 😄

Have a good night,

Dominik
0 Kudos