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

四、工具界面

边栏推荐
- (构造笔记)GRASP学习心得
- Jsup crawls Baidu Encyclopedia
- Sword finger offer05 Replace spaces
- 网上炒股开户安不安全?谁给回答一下
- Cloud Computing future - native Cloud
- Use of QT OpenGL camera
- QT OpenGL rotate, pan, zoom
- With pictures and texts, summarize the basic review of C language in detail, so that all kinds of knowledge points are clear at a glance?
- Flutter 退出登录二次确认怎么做才更优雅?
- OpenGL shader use
猜你喜欢

剑指Offer09. 用两个栈实现队列

剑指Offer06. 从尾到头打印链表

云计算未来 — 云原生

剑指Offer03. 数组中重复的数字【简单】
![[official MySQL document] deadlock](/img/2d/04e97d696f20c2524701888ea9cd10.png)
[official MySQL document] deadlock

Symlink(): solution to protocol error in PHP artisan storage:link on win10

公纵号发送提示信息(用户微服务--消息微服务)

Shardingsphere sub database and sub table < 3 >

OpenGL draws colored triangles

PHP export word method (phpword)
随机推荐
(构造笔记)MIT reading部分学习心得
102. Sequence traversal of binary tree
temp
写一个简单的nodejs脚本
JVM memory model
Unicode查询的官方网站
adb push apk
(构造笔记)ADT与OOP
2.8 overview of ViewModel knowledge
(construction notes) ADT and OOP
SystemVerilog -- OOP -- copy of object
DEJA_ Vu3d - 054 of cesium feature set - simulate the whole process of rocket launch
Basic knowledge of OpenGL (sort it out according to your own understanding)
(construction notes) grasp learning experience
Display time with message interval of more than 1 minute in wechat applet discussion area
145. Post order traversal of binary tree
[embedded] - Introduction to four memory areas
ES6 standard
(construction notes) learning experience of MIT reading
[download attached] password acquisition tool lazagne installation and use