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

    # Execute LineDensity
    outLineDensity = LineDensity(inPolylineFeatures,
                                 cellSize ,
                                 searchRadius ,

    # Save the output 

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.

| improve this question | | | | |
  • Does the raster have/need an attribute table for this tool? If you do not want to use a field name, maybe doing this for your variable is better: populationField = "". The way you have it scripted is it will be looking for a field called NONE. – crmackey Jan 14 '16 at 14:12
  • I did exactly what you said: replacing "NONE" by "", and I got the same error. – Jean Somers Jan 14 '16 at 16:12
  • And the "NONE" parameter worked fine in the PointDensity part of my complete script. – Jean Somers Jan 14 '16 at 16:17
  • I also tried to run the LineDensity tool in ArcMap. And it works fine: there is just a warning for Null and Empty entities. – Jean Somers Jan 15 '16 at 13:22
  • I guess I should develop a geometry check within my script. – Jean Somers Jan 15 '16 at 13:23

Ok, the script is fine. You can re-use it

The problem was projection redefinition between personalized and standards 10.x ESRI projections. My start data set was redefined and didn't work. I tested untouched data sets with a personalized projection and it worked well.

Finally I'll keep playing personalized and tackle redefinition when I'll be ready.

| improve this answer | | | | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.