• 一些Arcgis操作


    多值提取至点

    https://desktop.arcgis.com/zh-cn/arcmap/latest/tools/spatial-analyst-toolbox/extract-multi-values-to-points.htm

    参数说明数据类型
    in_point_features

    要添加栅格值的输入点要素。

    Feature Layer
    in_rasters
    [Raster, {Output Field Name}]

    要基于输入点要素的位置提取的输入栅格值。

    您还可以为存储栅格值的字段指定名称。默认情况下,将根据输入栅格数据集的名称创建唯一的字段名称。

    Extract Values
    bilinear_interpolate_values
    (可选)

    指定是否使用插值。

    • NONE — 不应用任何插值法;将使用像元中心值。这是默认设置。
    • BILINEAR — 将使用双线性插值法根据相邻像元的有效值计算像元值。除非所有相邻像元都为 NoData,否则会在插值时忽略 NoData 值。
    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) 
        
    
  • 相关阅读:
    C++一个类对象的大小计算
    C++多态及其实现原理
    C ++内存管理
    C++ 面向对象的三大特性和五个原则
    Liunx系统下的进程与线程
    selenium 常用方法
    Jenkins UI 自动化持续化集成测试
    教育数据挖掘可投的会议及期刊整理
    SonarQube-7.9.1+SQL Server2017在Windows环境下的安装与配置
    win10+Anaconda3+PyCharm 2019.1+python3.7-tensorflow-gpu1.13.1(RTX2080深度学习环境配置)
  • 原文地址:https://www.cnblogs.com/wkfvawl/p/16722678.html
Copyright © 2020-2023  润新知