ArcGIS之利用Arcpy批量进行栅格转面

首先在PyCharm中集成arcpy环境,然后再用python写代码

# coding:utf-8
import arcpy
import os
import re
from arcpy import env

# 栅格文件所在文件夹
input_raster_path = r"G:\\sci\\global30\\csj\\Cropland\\"  # type: str
# 输出shp文件所在文件夹
output_shp_path = r"G:\\dly\\csj\\cropland.gdb\\"
# 读取input_raster_path中的raster文件
arcpy.env.workspace = input_raster_path
rasters = arcpy.ListFiles("*.tif")
for raster in rasters:
    # 原raster文件名格式形如ntwd2010.tif
    # 提取文件名,作为输出文件的文件名
    print raster
    catchment_name = raster[:-4]
    print catchment_name
    shp_out_name = output_shp_path + catchment_name
    arcpy.RasterToPolygon_conversion(raster, shp_out_name, "true", "Value")
    print "finished"

你可能感兴趣的:(python,ArcGIS,批处理,python)