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

边栏推荐
猜你喜欢

If you can't learn, you have to learn. Jetpack compose writes an im app (I)

阿里 & 蚂蚁自研 IDE

Public and private account sending prompt information (user microservice -- message microservice)

Swagger

Prompt unread messages and quantity before opening chat group

Sword finger offer09 Implementing queues with two stacks
![[download attached] password acquisition tool lazagne installation and use](/img/21/eccf87ad9946d4177b600d96e17322.png)
[download attached] password acquisition tool lazagne installation and use

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?

Solve the problem of VI opening files with ^m at the end

Summary of development issues
随机推荐
Record your vulnhub breakthrough record
ES6 standard
Flutter Widget : Flow
The latest version of blind box mall thinkphp+uniapp
Sword finger offer07 Rebuild binary tree
02_ Lock the code, and don't let the "lock" become a worry
I'm too lazy to write more than one character
temp
最新版盲盒商城thinkphp+uniapp
【ManageEngine】IP地址扫描的作用
Fluent: Engine Architecture
CNN MNIST handwriting recognition
The difference between lambda and anonymous inner class
adb push apk
Flutter Widget : KeyedSubtree
Integer int compare size
Pki/ca and digital certificate
剑指Offer03. 数组中重复的数字【简单】
T430 toss and install OS majave 10.14
Sword finger offer06 Print linked list from end to end