2

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. enter image description here

2
  • This sounds like something you should consider contacting Esri support about. Have you looked at the TIN created by arcpy.ddd.CreateTin to ensure it's not empty or corrupt? Have you tried running arcpy.ddd.TinRaster from the python console in ArcGIS Pro? Commented Jan 25, 2023 at 1:13
  • @Michael Stimson - I can confirm that the output TIN has the expected values over the expected extent. I can confirm that both code snippets above produce the correct raster when using TIN to Raster in a ArcGIS Pro Python console window. It is odd that the resulting raster only contains nodata values on execution in WingIDE.
    – GBG
    Commented Jan 25, 2023 at 16:01

1 Answer 1

0

The line feature class and the input surface model did not share the same coordinate reference system. After reprojecting the input data into the same CRS the script worked as expected as an ArcGIS Pro toolbox scripting tool, or code posted to a Python window in Pro with data paths hardcoded.

In ArcGIS any raster to vector operation that did not share a CRS would return a dreaded 99999 error. I guess with some tools (model builder or a Python window) that might not be the case with some tools in Pro.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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