Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

CreateRandomPoints_management creates empty feature class

$
0
0
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!


Code:

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

Viewing all articles
Browse latest Browse all 2485

Trending Articles