2

I am looking for an easy solutions with Map Algebra for this one without Saving:

# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *
# Set environment settings
env.workspace = "C:/temp"
# Set local variables
inRaster = "DOM.tif"
inMask = "Mask.shp"
maskBuffer = "C:/temp/maskBuffer.shp"
temp = "C:/temp/temp.tif"
arcpy.Buffer_analysis(inMask, maskBuffer, "5 Meters")
outExtractByMask = ExtractByMask(inRaster, maskBuffer)
#is it possible to get the Minumum and Maximum directly from this Map Algebra?
outExtractByMask.save(temp)
tempRaster = Raster(outExtractByMask)
print(tempRaster.minumum)

This is a try to get the height of buildings in a loop, so I will ExtractByMask for each Feature in maskBuffer.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jan 4, 2020 at 22:19
0

2 Answers 2

1

outExtractByMask is a Raster object, no need to use tempRaster = Raster(outExtractByMask).

Raster objects have minimum and maximum properties.

You just need to calculate statistics to ensure those properties are not None.

outExtractByMask = ExtractByMask(inRaster, maskBuffer)
arcpy.CalculateStatistics_management(outExtractByMask)
print(outExtractByMask.minumum)
answered Jan 5, 2020 at 7:25
0

Although your question doesn’t explicitly ask for it, based on the description of your problem you may prefer to use Zonal Statistics As Table with your building footprints as zones (with a unique identifier field value for each building), with the "MIN_MAX" statistic.

That would avoid the requirement for looping. Just perform the zonal statistics operation and join the resulting table back to your building footprint layer.

answered Jan 5, 2020 at 11:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.