当前位置:网站首页>【ArcGIS自定义脚本工具】矢量文件生成扩大矩形面要素
【ArcGIS自定义脚本工具】矢量文件生成扩大矩形面要素
2022-07-03 11:55:00 【Salierib】
系列文章目录: ArcGIS自定义脚本工具
一、功能介绍
批量根据现有的要素(点、线、面)矢量文件(.shp)的范围生成扩大范围的矩形边界面要素文件(.shp)。扩大后面要素的坐标系与输入保持一致。输出矢量文件名格式(E_输入文件名.shp)

二、脚本代码
#!/usr/bin/python
# -*- coding: UTF-8 -*-
""" @File : CreateRetangleSHP.py @Author : salierib @Time : 2022/7/2 10:47 @QQ group: 582151631 @Version: """
import arcpy
import os
import arcgisscripting
shps = arcpy.GetParameterAsText(0)
outdir = arcpy.GetParameterAsText(1)
spacing = arcpy.GetParameterAsText(2)
shps = shps.split(";")
spacing = float(spacing)
def extents(fc):
extent = arcpy.Describe(fc).extent
west = extent.XMin
south = extent.YMin
east = extent.XMax
north = extent.YMax
return west, east, south, north
def text_create(out_txt_path, msg):
txt_file = open(out_txt_path, 'w')
txt_file.write(msg)
def rec_msg(xMin, yMin, xMax, yMax, spacing=0.2):
x1, y1 = xMin - spacing, yMin - spacing
x2, y2 = xMin - spacing, yMax + spacing
x3, y3 = xMax + spacing, yMax + spacing
x4, y4 = xMax + spacing, yMin - spacing
return x1, y1, x2, y2, x3, y3, x4, y4
for shp in shps:
out_corr = arcpy.Describe(shp).spatialReference
basename = os.path.basename(shp)[:-4]
xMin, xMax, yMin, yMax = extents(shp)
x1, y1, x2, y2, x3, y3, x4, y4 = rec_msg(xMin, yMin, xMax, yMax)
msg = """Polygon 0 0 0 {0} {1} 1.#QNAN 1.#QNAN 1 {2} {3} 1.#QNAN 1.#QNAN 2 {4} {5} 1.#QNAN 1.#QNAN 3 {6} {7} 1.#QNAN 1.#QNAN 4 {0} {1} 1.#QNAN 1.#QNAN END""".format(x1, y1, x2, y2, x3, y3, x4, y4, x1, y1)
out_txt = os.path.join(outdir, "E_%s.txt" % basename)
text_create(out_txt, msg)
gp = arcgisscripting.create()
inSep = "."
out_shp = os.path.join(outdir, "E_%s.shp" % basename)
gp.CreateFeaturesFromTextFile(out_txt, inSep, out_shp, out_corr)
三、工具参数

四、工具界面

边栏推荐
- QT OpenGL texture map
- DEJA_ Vu3d - 054 of cesium feature set - simulate the whole process of rocket launch
- 雲計算未來 — 雲原生
- 20. Valid brackets
- Dart: About zone
- 剑指Offer04. 二维数组中的查找【中等】
- [combinatorics] permutation and combination (summary of permutation and combination content | selection problem | set permutation | set combination)
- regular expression
- Sword finger offer07 Rebuild binary tree
- New features of ES6
猜你喜欢

Record your vulnhub breakthrough record

剑指Offer05. 替换空格

LeetCode 0556. Next bigger element III - end of step 4

Shutter: add gradient stroke to font

OpenGL draws colored triangles

The future of cloud computing cloud native

Self made pop-up input box, input text, and click to complete the event.

2.7 overview of livedata knowledge points
![[ManageEngine] the role of IP address scanning](/img/dc/df353da0e93e4d936c39a39493b508.png)
[ManageEngine] the role of IP address scanning

QT OpenGL texture map
随机推荐
Sword finger offer04 Search in two-dimensional array [medium]
idea将web项目打包成war包并部署到服务器上运行
Pragma pack syntax and usage
[embedded] - Introduction to four memory areas
Kubectl_ Command experience set
Dart: About zone
Dart: about grpc (I)
111. Minimum depth of binary tree
阿里大于发送短信(用户微服务--消息微服务)
DEJA_ Vu3d - cesium feature set 053 underground mode effect
Record your vulnhub breakthrough record
剑指Offer04. 二维数组中的查找【中等】
Flutter Widget : Flow
Wechat applet pages always report errors when sending values to the background. It turned out to be this pit!
145. Post order traversal of binary tree
MySQL time zone solution
01_ Using the concurrent tool class library, is thread safety safe
Use bloc to build a page instance of shutter
Basic knowledge of OpenGL (sort it out according to your own understanding)
OpenGL draws colored triangles