python代码分割栅格

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python代码分割栅格相关的知识,希望对你有一定的参考价值。

import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
import arcpy
import string

try:
raster = arcpy.GetParameterAsText(0) #clip raster
clip_feat = arcpy.GetParameterAsText(1) #clip featureclass
field = arcpy.GetParameterAsText(2) #name field
outworkspace = arcpy.GetParameterAsText(3) #output ws
outtype = arcpy.GetParameterAsText(4) #output ws
total = int(arcpy.GetCount_management(clip_feat).getOutput(0))
count = 1

for row in arcpy.SearchCursor(clip_feat):
mask = row.getValue("Shape")
extent = str(mask.extent.XMin)+" " +str(mask.extent.YMin)+" " +str(mask.extent.XMax)+" " +str(mask.extent.YMax)
outPath = outworkspace+"\\"+str(row.getValue(field)+outtype)
arcpy.AddMessage("chipping: " + str(row.getValue(field)) + "...count:"+str(total)+"\\"+str(count))
arcpy.Clip_management(raster,extent,outPath,mask,"0","ClippingGeometry")
count = count+1
except arcpy.ExecuteError:
print arcpy.GetMessages()

说这句错了for row in arcpy.SearchCursor(clip_feat):不明白,求指点

参考技术A 恐怕是你定义了一个叫做"len"的变量其当前数据类型为"int"

python touchdesigner-通用代码分割-generalEXT-示例

'''
    The MessageParser and General classes are intended to be the 
    classes that persist from project to project. The General class
    here takes care of fucntions that are universal to all projects. If 
    the function in question applies to only a specific project,
    then it fits better in the venue extension.
'''

messageParser = mod('messageParserEXT').MessageParser

class General(messageParser):
    def __init__(self, my_op):
        messageParser.__init__(self, my_op)
        print("General init")
        return

    def Change_switch(self, message):
        vals        = message.get('vals')

        op('constant1').par.value0 = vals

        return

以上是关于python代码分割栅格的主要内容,如果未能解决你的问题,请参考以下文章

python touchdesigner-通用代码分割-generalEXT-示例

AI十行代码系列5.人像分割-MediaPipe Python

ArcGIS批量导出栅格影像的属性表

GIS地理处理脚本案例教程——批量栅格分割-批量栅格裁剪-批量栅格掩膜-深度学习样本批量提取

Python对DICOM图像进行阈值分割

Split()分割函数Python实现源码