1

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
areaUnitScaleFactor)
File "C:\Program Files (x86)\Desktop10.3\ArcPy\arcpy\sa\Functions.py", line 446, in LineDensity
area_unit_scale_factor)
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
area_unit_scale_factor)
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.

closed as off-topic by PolyGeo Feb 24 '18 at 10:58

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the 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
0

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.

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