当前位置:网站首页>【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)
三、工具参数

四、工具界面

边栏推荐
- [download attached] password acquisition tool lazagne installation and use
- (构造笔记)ADT与OOP
- repo Manifest Format
- 2.7 overview of livedata knowledge points
- The future of cloud computing cloud native
- Sword finger offer06 Print linked list from end to end
- Dart: about Libraries
- PHP get the file list and folder list under the folder
- JVM memory model
- Write a simple nodejs script
猜你喜欢

Swagger

4000字超详解指针

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

使用BLoC 构建 Flutter的页面实例
![[MySQL special] read lock and write lock](/img/ac/e01c26882cc664ea2e5e731c5a8bab.png)
[MySQL special] read lock and write lock
![[ManageEngine] the role of IP address scanning](/img/dc/df353da0e93e4d936c39a39493b508.png)
[ManageEngine] the role of IP address scanning

Wechat applet pages always report errors when sending values to the background. It turned out to be this pit!

【附下载】密码获取工具LaZagne安装及使用

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

记录自己vulnhub闯关记录
随机推荐
OpenGL shader use
剑指Offer10- I. 斐波那契数列
JVM memory model
023(【模板】最小生成树)(最小生成树)
公纵号发送提示信息(用户微服务--消息微服务)
手机号码变成空号导致亚马逊账号登陆两步验证失败的恢复网址及方法
Develop plug-ins for idea
2020-09_ Shell Programming Notes
Lambda expression
2.8 overview of ViewModel knowledge
(construction notes) grasp learning experience
adb push apk
1-1 token
QT OpenGL rotate, pan, zoom
C language improvement article (wchar_t) character type
Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?
Laravel time zone timezone
Cloud Computing future - native Cloud
(构造笔记)GRASP学习心得
Flutter Widget : Flow