Con为空-在python中没有结果,但在Map代数中

447
2
跳到解决方案
06-14-2021 05:28 am
JohannesBierer
定期撰稿人

你好,

我对Con命令有问题。在python中只有一个空结果(没有错误消息),但如果我在ArcMaP中使用Map代数-光栅计算器有一个结果?版本ArcGIS Desktop 10.6.1

骗局有什么问题:

outas = Con((outClip > value2) & (outClip < value), outClip)

Value2比dgm中的value小0.1 m。例如Value: 907.1346 m和Value2: 907.0346 m

什么好主意吗?在第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)与arcpy.da。UpdateCursor(outLyr, ["POINT_Z", "POINT_Z_1"]) as cursor: for rin cursor: value = round(r[0], 4) print value r[1] = value cursor. updaterow (r) d = {} for rin arcpy.da。SearchCursor(outLyr, ["ORIG_FID", "POINT_Z_1"]): print r[0] d[r[0]] = r[1] for key, value in d.t iteritems(): # print value sel = "{} ={}"。format("ORIG_FID", key)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) #选择盆地BasinLyr = "BasinLyr" arcpy.MakeFeatureLayer_management(self. value)盆地外,盆地lyr) 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.save((outClip > value2) & (outClip < value), outClip) OutRas.save("OutRas_{}".format(ReplaceRstrR)) outFlood = value - OutRas outfluutung = Con(outFlood > 0, outFlood) outPut = "Zwischen_Height_{}".format(ReplaceRstrR) outfluutung .save(outPut) myList.append(outPut) self。outFLRaster = "AAA_FlHoehe_Gesamt_Kaltenbronn" arcpy。MosaicToNewRaster_management (myList arcpy.env。工作空间,\ self。outFLRaster, "",\ "32_BIT_FLOAT", "1", "1", "LAST","FIRST") arcpy.CheckInExtension(" space ")

0荣誉
1解决方案

接受的解决方案
DavidPike
通过 常规赛MVP
常规赛MVP

我相信你必须将outClip转换为一个Raster对象来使用映射代数语法,即arcpy。Raster(outClip)

outas = Con((arcpy.Raster(outClip) > value2) & (arcpy.Raster(outClip) < value), outClip)

在原帖子中查看解决方案

0荣誉
2回答
DavidPike
通过 常规赛MVP
常规赛MVP

我相信你必须将outClip转换为一个Raster对象来使用映射代数语法,即arcpy。Raster(outClip)

outas = Con((arcpy.Raster(outClip) > value2) & (arcpy.Raster(outClip) < value), outClip)

0荣誉
JohannesBierer
定期撰稿人

谢谢你,大卫,成功了!