Hello, I have a Kriging layer file, and on this file I tried to use the DensifySamplingNetwork_ga function in Arcpy. But I got an error:
Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "d:\arcgis 10.4.1\desktop10.4\arcpy\arcpy\ga.py", line 888, in DensifySamplingNetwork raise e ExecuteError: ERROR 999998: Unexpected Error. Failed to execute (DensifySamplingNetwork).
I just ran the following commands:
import arcpy
arcpy.CheckOutExtension("GeoStats")
arcpy.DensifySamplingNetwork_ga("D:\Kriging\KrigingLayer.lyr", 1, "D:\Kriging\Densify_1_200", "QUARTILE_THRESHOLD_UPPER", 200)
I can succeed on Windows 8 with ArcGIS 10.4.1, but the above error occurs on Windows 7 and 10 with ArcGIS 10.4.1 and 10.6.1, which is confusing. I'm attaching my Kriging layer file below.
Could someone please help me with this issue? Thank you!
Problem solved: it's because the layer file is storing an absolute path to the data. So I cannot directly densify this Kriging layer on another computer. Thanks everyone for replying!
a = "D:\test\KrigingLayer.lyr"
print(a)
D: est\KrigingLayer.lyr
# ---- you need 'raw' formatting
b = r"D:\test\KrigingLayer.lyr"
print(b)
D:\test\KrigingLayer.lyr
Sorry I didn't notice there is a \t in the path. I made up this 'test' directory name. I actually used other names without \t and arcpy.env when I executed the function , and this error occurs. I can succeed on one Windows 8 laptop.
Thank you very much for helping me!
raw encode fake paths as well
I changed the fake path.
/blogs/dan_patterson/2016/08/14/filenames-and-file-paths-in-python raw encoding is still recommended even for fake paths there are more obstacles in your 'path' so to speak
Hi Elisios,
I'm happy to take a look, but I will need a layer package rather than a layer file. A package will also send the underlying data for the layer, which I need in order to view it. Only do this is the data is not sensitive and you are ok with the public being able to download it.
Thanks,
Eric
I have attached the layer package file KrigingLayer.lpk above.
I can only successfully run this function and get the resultant shape file using the .lyr layer file on one Windows 8 laptop, but on all other computers it fails. I don't understand why. I have some other layer files that have the same issue.
Thank you very much for helping me!
Elisios
What happens if you use the geoprocessing tool and not Python?
I.e. add the layer to the display in ArcMap and then run the DensifySamplingNetwork geoprocessing tool.
I would also suggest that you use a shapefile or a file geodatabase rather than an XY layer. I.e. use the CopyFeatures tool.
Does your data have any spatial reference?
-Steve
It can succeed when using ArcMap GUI on all computers. From the documentation the function seems to only accept .lyr files as input. Yes the spatial reference is WGS 1984 (plain latitude/longitude).
I feel this is definitely a bug.