I'm trying to use LineDensity tool on polyline features. The shapefile is small and includes some invalid geometries.
The code I use is an adaptation of an ArcGIS Help script. Here is my code:
import arcpy from arcpy import env from arcpy.sa import * env.workspace = r"Z:\...\...\fdc\Grand_Ouest\33" # Parameters inPolylineFeatures = "_polyline.shp" populationField = "NONE" cellSize = 200 searchRadius = 500 areaUnitScaleFactor = "SQUARE_KILOMETERS" # Check out the ArcGIS Spatial Analyst extension license arcpy.CheckOutExtension("Spatial") # Execute LineDensity outLineDensity = LineDensity(inPolylineFeatures, populationField, cellSize , searchRadius , areaUnitScaleFactor) # Save the output outLineDensity.save(r"Z:\...\...\test.gdb\linedensity")
Here is the error I get from the code:
Traceback (most recent call last):
File "Z:/.../.../python/in_progress/linedensity_test.py", line 22, in
File "C:\Program Files (x86)\Desktop10.3\ArcPy\arcpy\sa\Functions.py", line 446, in LineDensity
File "C:\Program Files (x86)\Desktop10.3\ArcPy\arcpy\sa\Utils.py", line 53, in swapper
result = wrapper(*args, **kwargs)
File "C:\Program Files (x86)\Desktop10.3\ArcPy\arcpy\sa\Functions.py", line 439, in Wrapper
File "C:\Program Files (x86)\Desktop10.3\ArcPy\arcpy\geoprocessing_base.py", line 504, in
return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: ERROR 999999: Error executing function.
Failed to open raster dataset
Failed to execute (LineDensity).
I tried and modified my code more than once, primarily regarding the call of parameters and the use of environment module.
My last move was to discretize the arguments of LineDensity function by organizing them in separate lines. Now here we are: the only argument reported in the error is the last one, the area unit scale factor.
But that's the beginning of another question: cause the projection (RGF_1993_Lambert_93, epsg:2154), its measure unit (meter) and the scale factor (SQUARE_KILOMETERS) are perfectly consistent.
I suppose I've to try and find a new approach, with different data.
Little is to be found online on that matter except the link I delivered you at the beginning of the question.