日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python arcgis批量绘图_python调用ArcGIS批量生成多环缓冲区(多边形等距离放大)...

發(fā)布時間:2024/2/28 python 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python arcgis批量绘图_python调用ArcGIS批量生成多环缓冲区(多边形等距离放大)... 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

任務(wù)說明:需要對地圖文件進行要素轉(zhuǎn)面,繪制緩沖區(qū),最后面轉(zhuǎn)線,需要處理的文件有一百多個,手工處理費時費力,寫一個腳本,批量自動轉(zhuǎn)換

import os

import time

import arcpy

from arcpy import env

readme = '''批量繪制三級防御圈v1.0.1'''

'''

運行環(huán)境ArcGis10.7,python版本2.7

'''

# 要素轉(zhuǎn)面

def l2a(fn_in, fn_out):

if os.path.exists(('%s.shp' % fn_out).decode('utf-8')):

print('find:%s.shp' % fn_out)

return

if not fn_in.endswith('.shp'):

fn_in += '.shp'

arcpy.FeatureToPolygon_management(fn_in, fn_out, "", "NO_ATTRIBUTES", "")

# 繪制緩沖區(qū) 單位:千米 Kilometers

def zoom(fn_in, fn_out, i_zoom):

if os.path.exists(('%s.shp' % fn_out).decode('utf-8')):

print('find:%s' % fn_out)

return

if not fn_in.endswith('.shp'):

fn_in += '.shp'

# 緩沖區(qū)工具速度快,但無法合并重疊區(qū)域

# arcpy.Buffer_analysis(fn_in, fn_out, "%s Kilometers" % i_zoom, "FULL", "ROUND", "ALL", "Distance")

# 多環(huán)緩沖區(qū)工具速度慢,但可以合并重疊區(qū)域

arcpy.MultipleRingBuffer_analysis(fn_in, fn_out, [i_zoom], "Kilometers", "", "ALL")

# 面轉(zhuǎn)線

def a2l(fn_in, fn_out):

if os.path.exists(('%s.shp' % fn_out).decode('utf-8')):

print('find:%s' % fn_out)

return

if not fn_in.endswith('.shp'):

fn_in += '.shp'

arcpy.PolygonToLine_management(fn_in, fn_out, "IGNORE_NEIGHBORS")

# 按照放大距離繪制緩沖區(qū),單位千米

def task(fn_in, i_zoom):

print("input:%s" % fn_in)

i_t = time.time()

d1, f1 = os.path.split(fn_in)

fn_area = '%s/%s' % (d1, f1.replace('.shp', '_temp'))

l2a(fn_in, fn_area)

print('used:%-10.3f save:%s' % (time.time() - i_t, fn_area))

i_t = time.time()

fn_area_zoom = '%s/%s' % (d1, f1.replace('.shp', '_temp_%skm' % i_zoom))

zoom(fn_area, fn_area_zoom, i_zoom)

print('used:%-10.3f save:%s' % (time.time() - i_t, fn_area_zoom))

i_t = time.time()

fn_line_zoom = '%s/%s' % (d1, f1.replace('.shp', '_%skm' % i_zoom))

a2l(fn_area_zoom, fn_line_zoom)

print('used:%-10.3f save:%s' % (time.time() - i_t, fn_line_zoom))

# 遍歷目錄,批量處理線圖.shp文件

def check_dir(dir):

ls = os.listdir(dir.decode('utf-8'))

for l in ls:

# print(l)

dir2 = '%s/%s' % (dir, l.encode('utf-8'))

# print(dir2)

if os.path.isdir(dir2.decode('utf-8')):

check_dir(dir2)

if os.path.isfile(dir2.decode('utf-8')):

if not dir2.endswith('.shp'):

continue

ls_skip = ['各縣線圖', '各城區(qū)線圖', '青海縣邊界線圖', '青海各市邊界線圖']

if dir2.endswith('線圖.shp') or ('西寧四區(qū)' in dir2 and dir2.endswith('區(qū).shp')):

b_skip = False

for l_skip in ls_skip:

if l_skip in dir2:

b_skip = True

break

if not b_skip:

print(dir2)

fn_in = dir2

task(fn_in, 50)

task(fn_in, 100)

# 批量執(zhí)行

def auto():

dir = 'D:/arcgisfile_青海/線圖'

check_dir(dir)

# 執(zhí)行單個測試任務(wù)

def test():

dir = "D:/Program/Tem_Python/0010.WebConfig_py/0240.arcgis_shp2json/0003.src_arcgis/data"

fn_in = '%s/xx縣級線圖.shp' % dir

task(fn_in, 50)

task(fn_in, 100)

if __name__ == '__main__':

# test()

auto()

總結(jié)

以上是生活随笔為你收集整理的python arcgis批量绘图_python调用ArcGIS批量生成多环缓冲区(多边形等距离放大)...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。