当前位置:网站首页>[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

边栏推荐
- Sword finger offer06 Print linked list from end to end
- 145. Post order traversal of binary tree
- Fluent: Engine Architecture
- LeetCode 0556.下一个更大元素 III - 4步讲完
- Adult adult adult
- 1-1 token
- Flinksql can directly create tables and read MySQL or Kafka data on the client side, but how can it automatically flow and calculate?
- 【嵌入式】---- 内存四区介绍
- Alibaba is bigger than sending SMS (user microservice - message microservice)
- Airflow installation jump pit
猜你喜欢

【ArcGIS自定义脚本工具】矢量文件生成扩大矩形面要素

剑指Offer10- I. 斐波那契数列

Sword finger offer10- I. Fibonacci sequence

Sword finger offer06 Print linked list from end to end

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

Togaf certification self-study classic v2.0

Sword finger offer07 Rebuild binary tree

Take you to the installation and simple use tutorial of the deveco studio compiler of harmonyos to create and run Hello world?

New features of ES6

Shutter: overview of shutter architecture (excerpt)
随机推荐
Eureka self protection
Adult adult adult
257. All paths of binary tree
Display time with message interval of more than 1 minute in wechat applet discussion area
Pytext training times error: typeerror:__ init__ () got an unexpected keyword argument 'serialized_ options'
使用BLoC 构建 Flutter的页面实例
【附下载】密码获取工具LaZagne安装及使用
Use bloc to build a page instance of shutter
剑指Offer10- I. 斐波那契数列
Fluent: Engine Architecture
If you can't learn, you have to learn. Jetpack compose writes an im app (II)
adb push apk
初入职场,如何快速脱颖而出?
社交社区论坛APP超高颜值UI界面
Atomic atomic operation
It feels great to know you learned something, isn‘t it?
242. Effective letter heteronyms
Is it OK to open an account for online stock speculation? Is the fund safe?
[combinatorics] permutation and combination (summary of permutation and combination content | selection problem | set permutation | set combination)
Adult adult adult