Hello,
I've problems with a Con command. In python there is only a empty result (no error message), but if I use Map Algebra - raster calculator in ArcMaP there is a result? Version ArcGIS Desktop 10.6.1
What's wrong with the Con :
OutRas = Con((outClip > value2) & (outClip < value), outClip)
value2 is 0.1 m less than value in a dgm. For example Value: 907.1346 m und Value2: 907.0346 m
Any ideas? It's in line 64?
def ExpandSperren_1(self, outFC):
myList = list()
# outFC = Sperren_3D
outLyr = "outLyr"
arcpy.MakeFeatureLayer_management(outFC, outLyr)
arcpy.AddField_management(outLyr, "POINT_Z_1", "DOUBLE") # , 10, 4)
with arcpy.da.UpdateCursor(outLyr, ["POINT_Z", "POINT_Z_1"]) as cursor:
for r in cursor:
value = round(r[0], 4)
print value
r[1] = value
cursor.updateRow(r)
d = {}
for r in arcpy.da.SearchCursor(outLyr, ["ORIG_FID", "POINT_Z_1"]):
print r[0]
d[r[0]] = r[1]
for key, value in d.iteritems():
# print value
sel = "{} = {}".format("ORIG_FID", key)
print sel
arcpy.SelectLayerByAttribute_management(outLyr, "NEW_SELECTION", sel)
result = arcpy.GetCount_management(outLyr)
count = int(result.getOutput(0))
print("Count is {}".format(count))
value2 = value - 0.1
print "Value: {} und Value2: {}".format(value, value2)
# Select Basin
BasinLyr = "BasinLyr"
arcpy.MakeFeatureLayer_management(self.outBasin, BasinLyr)
arcpy.SelectLayerByLocation_management(BasinLyr, 'intersect', outLyr)
strR = round(value, 4)
print strR
ReplaceRstrR = str(strR).replace(".", "_")
outClip = "clip_{}".format(ReplaceRstrR)
arcpy.Clip_management("SperrenDGM", "", outClip, BasinLyr, "#", "ClippingGeometry", "NO_MAINTAIN_EXTENT")
arcpy.CheckOutExtension("Spatial")
OutRas = Con((outClip > value2) & (outClip < value), outClip)
OutRas.save("OutRas_{}".format(ReplaceRstrR))
outFlood = value - OutRas
outFlutung = Con(outFlood > 0, outFlood)
outPut = "Zwischen_Height_{}".format(ReplaceRstrR)
outFlutung.save(outPut)
myList.append(outPut)
self.outFLRaster = "AAA_FlHoehe_Gesamt_Kaltenbronn"
arcpy.MosaicToNewRaster_management(myList, arcpy.env.workspace, \
self.outFLRaster, "",\
"32_BIT_FLOAT", "1", "1", "LAST","FIRST")
arcpy.CheckInExtension("Spatial")
Solved! Go to Solution.
I believe you'd have to cast outClip into a Raster object to use that map algebra syntax i.e. arcpy.Raster(outClip)
OutRas = Con((arcpy.Raster(outClip) > value2) & (arcpy.Raster(outClip) < value), outClip)
I believe you'd have to cast outClip into a Raster object to use that map algebra syntax i.e. arcpy.Raster(outClip)
OutRas = Con((arcpy.Raster(outClip) > value2) & (arcpy.Raster(outClip) < value), outClip)
Thank you David, that worked!