当前位置:网站首页>[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
边栏推荐
- Integer string int mutual conversion
- 2020-09_ Shell Programming Notes
- Swagger
- 232. Implement queue with stack
- Introduction to concurrent programming (I)
- 【ArcGIS自定义脚本工具】矢量文件生成扩大矩形面要素
- Shutter widget: centerslice attribute
- 02_ Lock the code, and don't let the "lock" become a worry
- 111. Minimum depth of binary tree
- Tensorflow binary installation & Failure
猜你喜欢
剑指Offer10- I. 斐波那契数列
The latest version of blind box mall thinkphp+uniapp
公纵号发送提示信息(用户微服务--消息微服务)
Flutter 退出登录二次确认怎么做才更优雅?
2.7 overview of livedata knowledge points
ES6 standard
Alibaba is bigger than sending SMS (user microservice - message microservice)
TOGAF认证自学宝典V2.0
2.8 overview of ViewModel knowledge
T430 toss and install OS majave 10.14
随机推荐
Flinksql can directly create tables and read MySQL or Kafka data on the client side, but how can it automatically flow and calculate?
flinksql是可以直接客户端建表读mysql或是kafka数据,但是怎么让它自动流转计算起来呢?
Swift return type is a function of function
ImportError: No module named examples. tutorials. mnist
Sqoop1.4.4原生增量导入特性探秘
Pki/ca and digital certificate
2.7 overview of livedata knowledge points
剑指Offer05. 替换空格
225. Implement stack with queue
Do you feel like you've learned something and forgotten it?
Sword finger offer04 Search in two-dimensional array [medium]
剑指Offer10- I. 斐波那契数列
记录自己vulnhub闯关记录
Oh my Zsh + TMUX installation
使用BLoC 构建 Flutter的页面实例
Sword finger offer05 Replace spaces
The future of cloud computing cloud native
Kubectl_ Command experience set
LeetCode 0556.下一个更大元素 III - 4步讲完
Swift Error Handling