zoukankan      html  css  js  c++  java
  • arcpy 根据属性分类出图

    给一个伙计写的,实现ArcMap主窗口屏幕伪截图效果。

    代码实现的出图是出的数据视图的数据框,实现截图的效果,这得需要明白,布局视图咋搞自己搞,

    提供一个思路,不会搞的可以联系博主定制。

    import arcpy
    import os
    
    def GetFieldUniqueValue(inTable,inField):
        rows=arcpy.da.SearchCursor(inTable,inField)
        value_lst=[row[0] for row in rows]
        return set(value_lst)
    
    def main():
        layer=arcpy.GetParameter(0)
        field=arcpy.GetParameterAsText(1)
        outJpegDir=arcpy.GetParameterAsText(2)
        width=arcpy.GetParameter(3)
        height=arcpy.GetParameter(4)
        res=arcpy.GetParameter(5)
    
        mxd = arcpy.mapping.MapDocument("CURRENT")
        df = arcpy.mapping.ListDataFrames(mxd)[0]
    
        uniqueValues=GetFieldUniqueValue(layer,field)
    
        try:
            recordCount=len(uniqueValues)
            arcpy.SetProgressor("step","{} unique-values in this table.".format(recordCount),0,recordCount,1)
            for val in uniqueValues:
                arcpy.SetProgressorLabel("{} is exporting...".format(val))
                arcpy.SetProgressorPosition()
                arcpy.SelectLayerByAttribute_management(layer,"NEW_SELECTION","{0}='{1}'".format(field,val))
                df.zoomToSelectedFeatures()
                arcpy.SelectLayerByAttribute_management(layer,"CLEAR_SELECTION")#reset selected features as none.
                outJpegPath=os.path.join(outJpegDir,val+'.jpg')
                arcpy.AddMessage(outJpegPath)
                arcpy.mapping.ExportToJPEG (mxd, 
                    out_jpeg=outJpegPath,
                    data_frame=df, 
                    df_export_width=width,
                    df_export_height=height,
                    resolution=res, 
                    world_file=True, 
                    color_mode='24-BIT_TRUE_COLOR', 
                    jpeg_quality=100,
                    progressive=False
                    )
        except  Exception as e:
            arcpy.AddError(e.message)
    
    if __name__ == '__main__':
        main()
  • 相关阅读:
    网上图书商城项目学习笔记-001工具类测试
    SpringMVC,MyBatis商品的增删改查
    3.Spring-用反射模拟IoC
    2.Sprng-IoC-Java反射例子
    1.Spring IoC简单例子
    HTML5 文件API(二)
    HTML5 文件API(一)
    HTML5 编辑 API 之 Range 对象(二)
    hdu 5384 Danganronpa
    hdu 3065 病毒侵袭持续中
  • 原文地址:https://www.cnblogs.com/yzhyingcool/p/13708700.html
Copyright © 2011-2022 走看看