I have an ArcGIS script that detrends surfaces using transects. I am trying to update this tool for ArcGIS Pro. At TIN to Raster the resulting raster only contains no data values and I do not know why.
I have used ModelBuilder and the export to Python function to get this code, which when executed in a Python IDE (Wing) results in a raster with the expected values from the TIN.
import arcpy
def Model10(): # Model10
# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = False
# Check out any necessary licenses.
arcpy.CheckOutExtension("3D")
tin = "Z:\\GISpublic\\GerryG\\OtherMapRequests\\DetrendedDelta\\tin"
# Process: TIN To Raster (TIN To Raster) (3d)
tin_raster = "Z:\\GISpublic\\GerryG\\OtherMapRequests\\DetrendedDelta\\detrend.gdb\\tin_raster"
arcpy.ddd.TinRaster(in_tin=tin, out_raster=tin_raster, data_type="FLOAT", method="LINEAR", sample_distance="CELLSIZE", z_factor=1, sample_value=3)
tin_raster = arcpy.Raster(tin_raster)
if __name__ == '__main__':
# Global Environment settings
with arcpy.EnvManager(scratchWorkspace=r"Z:\GISpublic\GerryG\ArcProProjects\LummiBaseMap2018\LummiBaseMap2018.gdb", workspace=r"Z:\GISpublic\GerryG\ArcProProjects\LummiBaseMap2018\LummiBaseMap2018.gdb"):
Model10()
But when I use the same code in this Python script I get the NoData values only raster as an output. The paths to the data are good, I have read/write permissions to the directories. Why is the script below producing a raster with no data values?
import arcpy
from arcpy.sa import *
arcpy.SetProduct("ArcInfo")
arcpy.CheckOutExtension("3D")
arcpy.CheckOutExtension("Spatial")
workspace = r"Z:\GISpublic\GerryG\OtherMapRequests\DetrendedDelta\detrend.gdb"
tin = r"Z:\GISpublic\GerryG\OtherMapRequests\DetrendedDelta\tin"
transects = r"Z:\GISpublic\GerryG\OtherMapRequests\DetrendedDelta\detrend.gdb\mydata\trendlines"
theinputsurface = r"I:\SurfaceModels\LiDAR_2022_Topobathymetric\BareEarth\topo_bathy_bare_earth_2022.tif"
finalsurf = r"Z:\GISpublic\GerryG\OtherMapRequests\DetrendedDelta\mydataDTR_DEM.tif"
deletetempdata = "false"
arcpy.env.overwriteOutput = True
arcpy.env.workspace = workspace
arcpy.env.extent = theinputsurface
arcpy.env.snapRaster = theinputsurface
arcpy.env.cartographicCoordinateSystem = theinputsurface
arcpy.ddd.AddSurfaceInformation(transects, theinputsurface, "Z_MIN")
arcpy.ddd.CreateTin(tin, None, "trendlines Z_Min Soft_Line <None>", "DELAUNAY")
arcpy.ddd.TinRaster(tin, "tin_raster", "FLOAT", "LINEAR", "CELLSIZE", 1, 3)
arcpy.ddd.TinRaster(in_tin=tin, out_raster='tin_raster', data_type="FLOAT", method="LINEAR", sample_distance="CELLSIZE", z_factor=1, sample_value=3)
tin_raster = arcpy.Raster('tin_raster')
Here are the Python Environment variables for my Python IDE. Of course, I do not get an error on import arcpy, nor the other arcpy tools called before this so I believe the paths are correct.