python arcgis字段 arcgis中python脚本常用 您所在的位置:网站首页 arcgis的repair工具 python arcgis字段 arcgis中python脚本常用

python arcgis字段 arcgis中python脚本常用

2023-05-27 10:13| 来源: 网络整理| 查看: 265

在ArcGIS中制作Python脚本工具,批量合并个人地理数据库(*.mdb)

我们知道,在在ArcGIS工具箱中的工具有很多,共分为三类,一种是常见的工具,一种是模型工具,还有就是Python脚本工具,从图标就可以区分出来

python arcgis字段 arcgis中python脚本常用_python

这里我们主要说一下python脚本工具。python语言被称为胶水语言,实际工作中我们可以将一些批量的重复性的工作交给python来解决,从而解放我们的双手,节约我们的时间。我们以批量合并个人地理数据库(*.mdb)为例。

 

首先准备python代码# -*- coding: UTF-8 -*- import arcpy import os import ConversionUtils #Set the input datasets inputs = ConversionUtils.gp.GetParameterAsText(0) # The list is split by semicolons ";" inputs = ConversionUtils.SplitMultiInputs(inputs) #Set the output workspace output = ConversionUtils.gp.GetParameterAsText(1)

  try:

    

arcpy.env.workspace = output fcs = arcpy.ListFeatureClasses() fcs = fcs + arcpy.ListTables() dss = arcpy.ListDatasets() for File in inputs: for fc in fcs: arcpy.Append_management(File + "\\" + fc, output + "\\" + fc) for ds in dss: fcs1 = arcpy.ListFeatureClasses(feature_dataset = ds) for fc1 in fcs1: arcpy.Append_management(File + "\\" + ds + "\\" + fc1, output + "\\" + ds + "\\" + fc1) except arcpy.ExecuteError: print arcpy.GetMessages()

2.把以上python代码存为python文件(可以新建文本文档复制以上代码保存,后把拓展名改为(XXX.py)文件)

 SHAPE  \* MERGEFORMAT

python arcgis字段 arcgis中python脚本常用_右键_02

3.打开ArcMap,在目录中,工具箱/我的工具箱,右键,新建工具箱

python arcgis字段 arcgis中python脚本常用_数据库_03

python arcgis字段 arcgis中python脚本常用_右键_04

转存失败重新上传取消

python arcgis字段 arcgis中python脚本常用_右键_05

 

4.新建工具箱,右键添加/脚本

python arcgis字段 arcgis中python脚本常用_数据库_06

python arcgis字段 arcgis中python脚本常用_python_07

5.下一步,找到第2步保存的python文件,如下图

python arcgis字段 arcgis中python脚本常用_数据库_08

python arcgis字段 arcgis中python脚本常用_数据库_09

python arcgis字段 arcgis中python脚本常用_数据库_10

6.完成后得到这个脚本工具

python arcgis字段 arcgis中python脚本常用_python_11

7.最后把源数据都合并在目标数据库中,注意:源数据和目标数据库不要选重复。

python arcgis字段 arcgis中python脚本常用_数据库_12

8.确定,执行完成

python arcgis字段 arcgis中python脚本常用_右键_13

9.最后打开数据库发现数据都合在一起了

python arcgis字段 arcgis中python脚本常用_python_14

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有