介绍一些好用的ArcToolbox工具——数据处理(默认ArcGIS没有)

本文介绍了一系列GIS工具,包括从点要素创建多边形、构造凸壳、创建规则多边形等。这些工具适用于不同的GIS应用需求,如水力分析、多边形分割等。

Convert Points To Polygons



描述:
Creates an output polygon feature class based on point features and a field representing unique output features. An optional parameter can be used to control the order in which the input points are used.
创建基于点要素和字段表示唯一输出输出多边形要素类。可以使用可选的参数来控制使用的输入的点的顺序。

系统需求:
ArcGIS 9.3 or later
ArcView (Basic) license or higher


描述:
Creates a feature class containing polygons which represent a convex hull for each input feature.
创建一个包含表示为每个输入要素的凸形轮廓的多边形的要素类。

The geoprocessing Minimum Bounding Geometry tool can also be used to create convex hulls, but is only enabled to do so with an Advanced license.  This tool can be used across all license levels.
地理数据处理最低边界几何工具还可以用来创建凸壳,但仅启用,这样做与advanced的许可。跨越所有许可级别,可以使用此工具。

Built using a Python toolbox
使用 Python 工具箱生成

系统需求:
ArcGIS 10.1
Basic license or higher


描述:
Creates a hull rectangle polygon for each input feature's geometry. A hull rectangle is the most narrow enclosing rectangle.
创建每个输入的要素几何创建hull矩形多边形。hull矩形是最窄的封闭矩形。

系统需求:
ArcGIS 9.3 or later
ArcView (Basic) license or higher



描述:
Creates a transect that crosses through the centroid of each feature.
创建样条,通过每个要素的质心与相交。

Tool operates by creating internally a series of lines that transect the feature, but only the longest one is returned.  By default 180 lines are used to identify the longest transect. Fewer lines will generate results faster, but will generate less useful results. Greater number of lines will increase certainty, but will take longer.
通过创建内部的一系列的线横切功能操作工具,但只有最长的一个返回。默认情况下,使用180线识别最长的断面。较少的行会更快地产生结果,但会产生不太有用的结果。大的行数将增加确定性,但将需要更长的时间。

系统需求:
ArcGIS 10.1
Basic license or higher



描述:
Constructs point features at intervals along line features.
根据间隔点要素来创建线要素

系统需求:
ArcGIS 10.1
Basic license or higher


描述:
Converts input points to an output feature class of regular polygons (such as Pentagon, Hexagon, Heptagon, Octagon, etc.). A regular polygon is a polygon that has all sides and all interior angles equal. Can adjust the size, number of sides, and the rotation of the polygon.
转换的输入点,输出要素类正多边形的(如五边形,六边形,七边形,八角形等)。正多边形的多边形,有各方面的所有内角相等。可以调整的多边形的边的大小,数量,并且旋转。

系统需求:
ArcGIS 9.3 or later
ArcView (Basic) license or higher

Station Lines Arc10.0


描述:
Creates station lines (perpendicular lines) at user-specified points along a polyline.  Station lines are a useful first step for hydraulic analysis of rivers.
在用户指定的点沿折线​​创建站线(垂直线)。站线为河流水力分析,是一个非常有用的第一步。

访问和使用限制

Credit to the author



描述:
This modelbuilder tool allows you to split polygons with lines in a geoprocessing operation.  It is similar to Feature To Polygons, but it only splits existing polygons (from a user-defined layer) and does not create new polygons (where lines intersect).  It works by extending the lines to the bounding box of the polygon layer.  Requires ArcInfo license (because the tool uses Feature To Line, Feature to Polygon, Extend Line, and Identity).  A new output data layer is created.  All operations are done with "in_memory" datasets and do not effect the source data layers.
这个模型构建器工具允许您分割线,多边形的地理处理操作。这是一个类似功能,以多边形,但它只能拆分现有的多边形(一个用户定义的层)并没有创造新的多边形(线相交的地方)。它的工作原理,通过延长线,多边形层的边界框。需要ArcInfo许可(因为该工具使用特征线,特征到多边形,延长线,和Identity)。创建一个新的输出数据层。所有的操作都​​完成了“in_memory”数据集,不影响源数据层。

The "Extend Lines" operation can be very slow.  You can speed up this operation up by setting a limit to how far the lines will attempt to extend.  This will also help limit long straight lines, which can be undesirable if splitting with curvy road or water linework.
“延长线”的操作可能会很慢。您可以加快这一操作多远的线条将尝试通过设置限制。这也将有助于限制长的直线,这是不可取的分裂与弯曲的路面或水面线条。

This tool was inspired by the discussion at: http://gis.stackexchange.com/questions/31965/is-there-an-automated-geoprocesing-tool-in-arcgis-to-slice-clip-or-cut-polygon


描述:
Takes two polygons and unions them to find the overlapping area, area belonging to neither polygon, then adds areas belonging to one polygon or another if they are closer to the intersection than the non-union area.

访问和使用限制

No constraints.  Just credit the author.


Cone line buffer



描述:
Create cone from line buffer with min buffer value at the start line and with max buffer value at the end line
创建锥行缓冲区的最小缓冲值的起始行和最大缓冲值在端线

访问和使用限制

Build for ArcGIS for Desktop 10.0.

Convert miles to meters.



附赠一个,如果进行智能化的GP处理,处理完毕后给相关人员发个邮件也是一个很好的体验!
描述
This geoprocessing script tool allows you to send email with or without file attachments in any format. The tool also allows you to configure the public Email server such as GMail or Yahoo as a SMTP server so when you travel or are in the field without access to an internal mail server, you can still use the tool as part of a model or service. 
此地理处理脚本工具允许您发送电子邮件,带或不带任何格式的文件附件。该工具还允许您配置公用的,如Gmail或Yahoo的电子邮件服务器作为SMTP服务器,以便当您旅行或身在外地没有访问到内部邮件服务器,你仍然可以使用该工具的模型或服务的一部分。


访问和使用限制
Unzip the zip file to a python toolbox and use it like a regular system tool. If you want to configure the SMTP server to a public mail server, it only supports GMail and Yahoo. For other email servers, please check the port number and modify the code. When configure Gmail or Yahoo server, make sure the two support port numbers 465 and 587 are not blocked within the internal network. If they are blocked, check your administrator or use the external network. 
zip文件解压缩到一个python工具箱,并使用它像一个普通的系统工具。如果你想配置一个公共的邮件服务器SMTP服务器,它仅支持Gmail和雅虎。对于其他电子邮件服务器,请检查端口号,并修改代码。当Gmail或Yahoo服务器配置,确保没有阻止内部网络中的两个支持端口465和587号。如果他们被封锁,请检查您的系统管理员或使用外部网络。
<think>好的,我现在需要解决用户的问题,即如何使用ArcGIS的arcpy实现数据驱动批量导出MXD文档并同步生成图片,并将其封装为GIS脚本工具。首先,我得回忆一下arcpy的相关知识,尤其是涉及数据驱动页面和导出图片的部分。 用户提到要批量处理多个MXD文档,并且每个文档都要生成对应的图片。这可能涉及到遍历多个mxd文件,对每个文件应用数据驱动页面的设置,然后导出为图片格式。同时,用户希望将这些操作封装成脚本工具,方便其他用户使用,而无需编写代码。 首先,我需要确定数据驱动页面的设置。数据驱动页面允许用户基于某个图层的属性来生成多个页面,每个页面可以对应不同的区域或要素。在arcpy中,应该可以通过DataDrivenPages对象来处理这个功能。例如,使用arcpy.mapping模块中的DataDrivenPages类来循环每个页面并导出。 接下来是处理多个MXD文件。这需要脚本能够接收输入文件夹路径,遍历其中的所有mxd文件。对于每个mxd,打开文档,检查是否启用了数据驱动页面,然后逐个导出页面为图片。可能需要设置输出路径和图片格式,比如PNG或PDF。 然后是导出图片的具体参数。比如分辨率、图片大小、是否透明等。这些参数可以通过arcpy的导出函数来设置,比如ExportToPNG或ExportToPDF,并传入相应的参数。 封装为脚本工具的话,需要创建Python工具箱,定义参数,比如输入文件夹、输出路径、图片格式、分辨率等。在脚本工具中,用户可以通过图形界面选择这些参数,而不需要修改代码。同时,参数的验证和默认值也需要考虑,比如图片格式的下拉列表,分辨率的默认值设置。 此外,还需要考虑异常处理,比如某个mxd文件无法打开或没有启用数据驱动页面时,脚本应该跳过并记录错误,而不是中断整个处理过程。使用try-except块来捕获异常,并输出提示信息。 参考用户提供的引用内容,特别是引用[2]和[3],关于如何创建Python工具箱,设置参数,以及使用arcpy.GetParameterAsText获取用户输入。例如,输入文件夹参数应该设置为工作空间类型,输出路径为文件夹类型,图片格式使用下拉列表选择,分辨率作为可选数值输入。 可能还需要考虑性能优化,比如在处理大量mxd文件或页面时,如何有效管理内存,及时释放资源。比如在每次处理完一个mxd后,使用del语句释放地图文档对象,或者使用with语句来管理资源。 最后,测试脚本工具的功能,确保所有参数正确传递,导出的图片符合预期,并且工具能够处理各种异常情况。可能需要提供使用说明或注释,帮助用户正确使用工具。 总结步骤大致如下: 1. 遍历输入文件夹中的所有mxd文件。 2. 对于每个mxd,打开文档,检查数据驱动页面是否启用。 3. 如果启用,遍历每个页面,导出为指定格式的图片,保存在输出文件夹中。 4. 处理异常情况,记录错误信息。 5. 将脚本封装为Python工具工具,设置输入输出参数,并添加参数验证和帮助信息。</think>以下是如何使用ArcGIS arcpy实现数据驱动批量导出MXD文档并生成图片,最终封装为脚本工具的完整解决方案: ### 一、实现原理 通过arcpy.mapping模块操作MXD文档,结合数据驱动页面(Data Driven Pages)功能实现批量导出。每个MXD文档根据预设的驱动要素字段自动生成多个地图页面,并以指定格式导出为独立图片文件[^1]。 ### 二、Python脚本实现 ```python import arcpy import os def export_mxd_batch(input_folder, output_folder, img_format="PNG", dpi=300): """ 批量导出MXD文档的数据驱动页面为图片 :param input_folder: 包含MXD文件的输入文件夹路径 :param output_folder: 图片输出目录 :param img_format: 图片格式(PNG/PDF/JPEG) :param dpi: 输出分辨率 """ arcpy.env.overwriteOutput = True for filename in os.listdir(input_folder): if not filename.lower().endswith(".mxd"): continue mxd_path = os.path.join(input_folder, filename) try: mxd = arcpy.mapping.MapDocument(mxd_path) ddp = mxd.dataDrivenPages if not ddp.enabled: arcpy.AddWarning(f"{filename} 未启用数据驱动页面,已跳过") continue base_name = os.path.splitext(filename)[0] output_sub = os.path.join(output_folder, base_name) os.makedirs(output_sub, exist_ok=True) for pageNum in range(1, ddp.pageCount + 1): ddp.currentPageID = pageNum page_name = ddp.pageRow.getValue(ddp.pageNameField.name) output = os.path.join(output_sub, f"{page_name}.{img_format.lower()}") if img_format == "PDF": ddp.exportToPDF(output, resolution=dpi) else: ddp.exportToPNG(output, resolution=dpi) del mxd arcpy.AddMessage(f"成功处理: {filename}") except Exception as e: arcpy.AddError(f"处理 {filename} 失败: {str(e)}") if __name__ == "__main__": # 脚本参数获取 input_folder = arcpy.GetParameterAsText(0) output_folder = arcpy.GetParameterAsText(1) img_format = arcpy.GetParameterAsText(2) dpi = int(arcpy.GetParameterAsText(3)) export_mxd_batch(input_folder, output_folder, img_format, dpi) ``` ### 三、创建Python脚本工具 1. **新建Python工具箱** - 在ArcCatalog中右键点击目标文件夹 → 新建 → Python工具箱[^2] - 命名后右键选择"编辑",粘贴上述代码 2. **配置工具参数** ```python def getParameterInfo(self): params = [ arcpy.Parameter( displayName="输入MXD文件夹", name="input_folder", datatype="DEFolder", parameterType="Required", direction="Input"), arcpy.Parameter( displayName="输出文件夹", name="output_folder", datatype="DEFolder", parameterType="Required", direction="Input"), arcpy.Parameter( displayName="图片格式", name="img_format", datatype="GPString", parameterType="Required", direction="Input"), arcpy.Parameter( displayName="输出分辨率(DPI)", name="dpi", datatype="GPLong", parameterType="Optional", direction="Input") ] # 设置格式下拉列表 params[2].filter.list = ["PNG", "PDF", "JPEG"] params[2].value = "PNG" params[3].value = 300 return params ``` 3. **设置工具属性** ```python def __init__(self): self.label = "批量导出数据驱动页面" self.description = "批量处理MXD文档的数据驱动页面导出为图片" self.canRunInBackground = True ``` ### 四、工具使用说明 1. 输入参数配置: - **输入MXD文件夹**:包含需要处理的*.mxd文件 - **输出文件夹**:生成图片的存储目录 - **图片格式**:支持PNG/PDF/JPEG三种格式 - **分辨率**:默认300DPI,可选参数 2. 前置条件: - 所有MXD文档必须已配置数据驱动页面 - 确保输出文件夹有写入权限 3. 输出结果: - 为每个MXD创建同名子文件夹 - 在子文件夹内生成按页面命名的图片文件 ### 五、优化建议 1. 添加异常处理机制,跳过损坏的MXD文件 2. 支持多线程处理提升批量导出速度 3. 增加日志记录功能,生成处理报告 4. 可扩展支持TIFF/BMP等更多输出格式
评论 12
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值