TransWikia.com

Raster algebra (subtract) changes extent of output

Geographic Information Systems Asked on February 25, 2021

I have a tool that calculates volume of a portion of a raster DTM. I first clip a portion of the entire raster then fill it. I then subtract the clipped original from the filled raster. My problem is that if my project only has the DTM as part of it, it works fine. However if I include a much larger DTM in the Table of Contents, it doesn’t, even though the larger raster is not referenced by the code. What happens is that the difference raster now has the extents of the larger raster and the differences are now near the upper left corner, instead of being aligned with the clipped & filled rasters. So under the first condition, the difference raster is 462×365, but in the second case, it balloons to 39000×39000, the extent of the second DTM.

I have included a set extent statement, but that seems to make no difference. Below is the offending part of the code. OK up to rastercalc_temp, but that raster has the aberrant dimensions.

Input_DEM = arcpy.GetParameterAsText(0)
Aguada_rectangular_boundaries = arcpy.GetParameterAsText(1)
Aguada_geodatabase = arcpy.GetParameterAsText(2)

# Set Geoprocessing environments
tempEnvironment0 = arcpy.env.extent
arcpy.env.extent = Aguada_rectangular_boundaries
arcpy.env.scratchWorkspace = "C:UsersWilliamDesktopModelBuilderScratchAguada_scratch.gdb"
arcpy.env.workspace = "C:UsersWilliamDesktopModelBuilderScratchAguada_scratch.gdb"

# Local variables:
Clipped_raster = "Clipped_raster"

# Process: Clip
arcpy.Clip_management(Input_DEM, "", Clipped_raster, Aguada_rectangular_boundaries, "-3.402823e+038", "ClippingGeometry", "MAINTAIN_EXTENT")

# Process: Fill
Fill_NCALM = arcpy.sa.Fill(Clipped_raster)
Fill_NCALM.save("Filled_raster")

rastercalc_temp = Raster("Filled_raster") - Raster("Clipped_raster")
rastercalc_temp.save("rastercalc_temp")

I have noticed that Clipped_raster and Fill_raster differ by 1 pixel depending on the options for Clip_management. However, I played around with the various possibilities with the same result.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP