当前位置:网站首页>[ArcGIS user defined script tool] vector file generates expanded rectangular face elements
[ArcGIS user defined script tool] vector file generates expanded rectangular face elements
2022-07-03 12:38:00 【Salierib】
List of articles
List of articles : ArcGIS Custom script tools
One 、 Function is introduced
Batch based on existing elements ( spot 、 Line 、 Noodles ) Vector files (.shp) Generate an expanded rectangular edge interface feature file (.shp). Expand the coordinate system of the following elements to be consistent with the input . Output vector file name format (E_ Input file name .shp)
Two 、 Script code
#!/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)
3、 ... and 、 Tool parameters
Four 、 Tool interface
边栏推荐
- Write a simple nodejs script
- 剑指Offer04. 二维数组中的查找【中等】
- Fundamentals of concurrent programming (III)
- 【嵌入式】---- 内存四区介绍
- node的ORM使用-Sequelize
- 阿里 & 蚂蚁自研 IDE
- Slf4j log facade
- 剑指Offer10- I. 斐波那契数列
- Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?
- 双链笔记·思源笔记综合评测:优点、缺点、评价
猜你喜欢
最新版抽奖盲盒运营版
LeetCode 0556. Next bigger element III - end of step 4
Swagger
[download attached] password acquisition tool lazagne installation and use
Togaf certification self-study classic v2.0
Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?
【ArcGIS自定义脚本工具】矢量文件生成扩大矩形面要素
实现验证码验证
TOGAF认证自学宝典V2.0
剑指Offer06. 从尾到头打印链表
随机推荐
Shutter widget: centerslice attribute
Recovery of website address and method of Amazon account login two-step verification failure caused by mobile phone number becoming empty
Kubectl_ Command experience set
2.6 preliminary cognition of synergetic couroutines
Sword finger offer09 Implementing queues with two stacks
云计算未来 — 云原生
Lambda表达式
十條職場規則
使用BLoC 构建 Flutter的页面实例
Sqoop1.4.4原生增量导入特性探秘
Applet wxss introduction
temp
[combinatorics] permutation and combination (example of permutation and combination)
Swift Error Handling
How to deploy web pages to Alibaba cloud
【附下载】密码获取工具LaZagne安装及使用
Day 1 of kotlin learning: simple built-in types of kotlin
Flutter Widget : KeyedSubtree
剑指Offer06. 从尾到头打印链表
Approve iPad, which wants to use your icloud account