Having difficulty with the following script. A couple of variables to know about are not shown but have been run prior to this snippet, they are:
outrasterpath = r"S:/General-Offices-GO-Trans/SLR-Mapping/GIS_Projects_2018/Smart_T_Line_Model/geodata/TEST_RASTERCLIP.gdb/"
outrastertopoint = r"S:/General-Offices-GO-Trans/SLR-Mapping/GIS_Projects_2018/Smart_T_Line_Model/geodata/TEST_RASTERTOPOINT.gdb/"
arcpy.env.workspace = outrasterpath rasterList = arcpy.ListRasters("*", "GRID") for raster in rasterList: arcpy.conversion.RasterToPoint(raster, outrastertopoint + raster, "Pixel Value") Traceback (most recent call last): File "<string>", line 2, in <module> File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\conversion.py", line 195, in RasterToPoint raise e File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\conversion.py", line 192, in RasterToPoint retval = convertArcObjectToPythonObject(gp.RasterToPoint_conversion(*gp_fixargs((in_raster, out_point_features, raster_field), True))) File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 496, in <lambda> return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. ERROR 000860: Input raster: is not the type of Composite Geodataset, or does not exist. ERROR 001000: Field: Field Pixel Value does not exist Failed to execute (RasterToPoint).
A few other bits of info. I have tried "VALUE", "Pixel value", and "Stretch.Pixel Value" for the last argument, none work.
Have left the () with no inputs on Line 2 with no luck.
Thanks for any help!
throw a print statement in at line 3.5.
you don't raw encode (ie r ) forward-slashed paths (can't remember if it is an issue but it shouldn't be there)
And the biggie... it requires a 'raster layer' as input, not a file on disk unless it is a *.lyr which wouldn't be in a gdb anyway. So you will have to add a
to the workflow
The forward slashes have not been issue so far.
Here’s the result of the print:
So, that is OK.
I did change a line of code as I had “raster” meaning a pathname to a grid that was used for clipping earlier in the script as opposed to it being referenced in the
For raster in rasterList:
lets try print(raster) since print(rasterlist) didn't appear to print (or is it a copy past issue),
You still need a rasterlayer… which isn't a raster per se but a *.lyr *.lyrx or it is a 'layer' open in arcmap or Pro
Here’s the result of both print(raster) and print(rasterlist). In this script it’s looping thru 5 grids, from rasterlist:
Since it is going to be 1,455 rasters in the loop I was hoping to not have to run another conversion prior to running the raster to point.
SO, I’m hoping for another solution but will attempt to use this if no other solutions come in.
Try one... from the example they use a *.img… I have tested with *.tiff that is both seem to be standalone files, so the gdb raster stuff, you will have to see if it works.
import arcpy from arcpy import env env.workspace = "C:/data" # ---- notice, a folder with a raster dataset arcpy.RasterToPoint_conversion("source.img", "c:/output/source.shp", "VALUE")
if it works for one raster that you know of then you should be good.
I wouldn't even change the shapefile output until you know the process works
replace env.workspace with your gdb path
replace source.img with your 'raster' name
Try specifying the entire path for the input raster, rather than relying on the workspace env. If that doesn't work, try running the tool on its own (outside any loop), hardcoding the values that you think should work, and work backwards from there. Things I see that can make easy mistakes in your code: concatenating path components (should try to use os.path.join), using FGDB rasters, relying on envs, specifying a field that probably doesn't exist, and I'm not sure that FGDB rasters are GRID format (although it seems to be working for you).