多值提取至点
参数 | 说明 | 数据类型 |
in_point_features | 要添加栅格值的输入点要素。 | Feature Layer |
in_rasters[Raster, {Output Field Name}] | 要基于输入点要素的位置提取的输入栅格值。 您还可以为存储栅格值的字段指定名称。默认情况下,将根据输入栅格数据集的名称创建唯一的字段名称。 | Extract Values |
bilinear_interpolate_values(可选) | 指定是否使用插值。
| Boolean |
使用插值法将多个栅格的像元值提取到 shapefile 点要素类的属性中。
# Name: ExtractMultiValuesToPoints_Ex_02.py
# Description: Extracts the cells of multiple rasters as attributes in
# an output point feature class. This example takes a multiband IMG
# and two GRID files as input.
# Requirements: Spatial Analyst Extension
# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *
# Set environment settings
env.workspace = "C:/sapyexamples/data"
# Set local variables
inPointFeatures = "poi.shp"
inRasterList = [["doqq.img", "doqqval"], ["redstd", "focalstd"],
["redmin", "focalmin"]]
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute ExtractValuesToPoints
ExtractMultiValuesToPoints(inPointFeatures, inRasterList, "BILINEAR")
shp转csv
直接使用geopandas库读取
#加载geopandas
import geopandas as gpd
#读取geopandas
shp_file = r'E:\projects\weather\\VIIRS\样本点全2.shp'
df_geo = gpd.read_file(shp_file)
删除geometry坐标信息
del df_geo['geometry']
csv转shp
详见之前文章
https://www.cnblogs.com/wkfvawl/p/16676691.html
grd转tif
将Mrh文件下的所有grd文件都转成tif文件
import arcpy
from arcpy.sa import *
import sys, string, os
idx = 'Mrh'
dir = r'E:\projects\weather\ANUSPLIN\mapdata\\'
path = dir + idx
files = os.listdir(path)
for f in files:
if os.path.splitext(f)[1] == '.grd':
Input_raster_file = path + os.sep + f
Raster_Format = "TIFF"
Output_Workspace = path
basename = os.path.splitext(f)[0]
Output_raster = Output_Workspace + os.sep + basename + '.tif'
arcpy.RasterToOtherFormat_conversion(Input_raster_file, Output_Workspace, Raster_Format)
print(Output_raster)
os.remove(Input_raster_file)
批量裁剪栅格
核心ExtractByMask函数,两个参数一个是被裁剪的栅格名,另一个是裁剪用的shp
import arcpy
from arcpy.sa import *
import sys, string, os
path = r'E:\数据\NDVI\\'
new = r'E:\数据\NDVI_tif\\'
shp = "E:\projects\weather\ANUSPLIN\mapdata\云南省.shp"
files = os.listdir(path)
for f in files:
name = 'ndvi' + f + 'a'
out = new + f + '.tif'
raster = arcpy.Raster(path + f + '\\' + name)#读取adf文件
outExtractByMask = ExtractByMask(raster,shp)
outExtractByMask.save(out)
标签:shp,raster,os,Arcgis,import,一些,path,操作,arcpy
From: https://www.cnblogs.com/wkfvawl/p/16722678.html