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

四、工具界面

边栏推荐
- 剑指Offer04. 二维数组中的查找【中等】
- 记录自己vulnhub闯关记录
- wpa_ cli
- Redis notes 01: Introduction
- QT OpenGL texture map
- 102. Sequence traversal of binary tree
- Eureka self protection
- 111. Minimum depth of binary tree
- LeetCode 0556.下一个更大元素 III - 4步讲完
- Itext7 uses iexternalsignature container for signature and signature verification
猜你喜欢

Sword finger offer10- I. Fibonacci sequence

TOGAF认证自学宝典V2.0

QT OpenGL rotate, pan, zoom

Itext7 uses iexternalsignature container for signature and signature verification

Eureka自我保护

Sword finger offer06 Print linked list from end to end

OpenGL draws colored triangles

Wechat applet pages always report errors when sending values to the background. It turned out to be this pit!
![[official MySQL document] deadlock](/img/2d/04e97d696f20c2524701888ea9cd10.png)
[official MySQL document] deadlock

Cloud Computing future - native Cloud
随机推荐
剑指Offer07. 重建二叉树
Eureka self protection
Slf4j log facade
2020-11_ Technical experience set
temp
(构造笔记)MIT reading部分学习心得
Shutter: about inheritedwidget
OpenGL draws colored triangles
Wechat applet development - page Jump transfer parameters
2020-09_ Shell Programming Notes
102. Sequence traversal of binary tree
Swagger
Introduction to concurrent programming (I)
写一个简单的nodejs脚本
JVM内存模型
error: expected reference but got (raw string)
剑指Offer10- I. 斐波那契数列
Use Tencent cloud IOT platform to connect custom esp8266 IOT devices (realized by Tencent continuous control switch)
TOGAF认证自学宝典V2.0
RedHat5 安装Socket5代理服务器