Spatial Analyst Tools
1、区域分析
# Process: 以表格显示分区几何统计
arcpy.gp.ZonalGeometryAsTable_sa("", "", 输出表, "")
# Process: 以表格显示分区统计
arcpy.gp.ZonalStatisticsAsTable_sa("", "", "", 输出表__2_, "DATA", "ALL")
# Process: 分区几何统计
arcpy.gp.ZonalGeometry_sa("", "", 输出栅格, "AREA", "")
# Process: 分区统计
arcpy.gp.ZonalStatistics_sa("", "", "", 输出栅格__2_, "MEAN", "DATA")
# Process: 区域填充
arcpy.gp.ZonalFill_sa("", "", 输出栅格__3_)
# Process: 区域直方图
arcpy.gp.ZonalHistogram_sa("", "", "", 输出表__3_, 输出图表名称)
# Process: 面积制表
arcpy.gp.TabulateArea_sa("", "", "", "", 输出表__4_, "")
2、叠加分析
# Process: 加权叠加
arcpy.gp.WeightedOverlay_sa("", 输出栅格)
# Process: 加权总和
arcpy.gp.WeightedSum_sa("", 输出栅格__2_)
# Process: 查找区域
arcpy.gp.LocateRegions_sa("", 输出栅格__3_, "", "SQUARE_MAP_UNITS", "1", "CIRCLE", "0", "50", "HIGHEST_AVERAGE_VALUE", "", "", "", "", "MAP_UNITS", "", "EIGHT", "NO_ISLANDS", "AUTO", "AUTO", "AUTO")
# Process: 模糊叠加
arcpy.gp.FuzzyOverlay_sa("", 输出栅格__4_, "AND", "0.9")
# Process: 模糊隶属度
arcpy.gp.FuzzyMembership_sa("", 输出栅格__5_, "MSSMALL 1 1", "NONE")
3、地下水分析
# Process: 孔隙扩散
arcpy.gp.PorousPuff_sa("", "", "", 输出栅格, "", "", "", "3", "1", "0")
# Process: 粒子追踪
arcpy.gp.ParticleTrack_sa("", "", "", 输出粒子追踪文件, "", "", 输出追踪折线要素)
# Process: 达西流
arcpy.gp.DarcyFlow_sa("", "", "", "", 输出地下水水量平衡残差栅格数据, 输出方向栅格数据, 输出量级栅格数据)
# Process: 达西速度
arcpy.gp.DarcyVelocity_sa("", "", "", "", 输出方向栅格数据__2_, 输出量级栅格数据__2_)
4、地图代数
# Process: 栅格计算器
arcpy.gp.RasterCalculator_sa("", 输出栅格)
5、多元分析
# Process: Iso 聚类
arcpy.gp.IsoCluster_sa("", 输出特征文件, "", "20", "20", "10")
# Process: Iso 聚类非监督分类
arcpy.gp.IsoClusterUnsupervisedClassification_sa("", "", 输出分类的栅格数据, "20", "10", 输出特征文件__2_)
# Process: 主成分分析
arcpy.gp.PrincipalComponents_sa("", 输出多波段栅格, "", 输出数据文件)
# Process: 创建特征文件
arcpy.gp.CreateSignatures_sa("", "", 输出特征文件__3_, "COVARIANCE", "")
# Process: 最大似然法分类
arcpy.gp.MLClassify_sa("", "", 输出分类的栅格数据__2_, "0.0", "EQUAL", "", 输出置信栅格)
# Process: 树状图
arcpy.gp.Dendrogram_sa("", 输出树状图文件, "VARIANCE", "78")
# Process: 波段集统计
arcpy.gp.BandCollectionStats_sa("", 输出统计文件, "BRIEF")
# Process: 类别概率
arcpy.gp.ClassProbability_sa("", "", 输出多波段栅格__2_, "100", "EQUAL", "")
# Process: 编辑特征文件
arcpy.gp.EditSignatures_sa("", "", "", 输出特征文件__4_, "10")
6、太阳辐射
# Process: 太阳辐射区域
arcpy.gp.AreaSolarRadiation_sa("", 输出总辐射栅格, "45", "200", "MultiDays 2021 5 160", "14", "0.5", "NOINTERVAL", "1", "FROM_DEM", "32", "8", "8", "UNIFORM_SKY", "0.3", "0.5", 输出直接辐射栅格数据, 输出散射辐射栅格数据, 输出直接辐射持续时间栅格数据)
# Process: 太阳辐射图
arcpy.gp.SolarRadiationGraphics_sa("", 输出视域栅格数据, "", "200", "0", "32", "45", "MultiDays 2021 5 160", "14", "0.5", 输出太阳图栅格, "8", "8", 输出星空图栅格)
# Process: 太阳辐射点
arcpy.gp.PointsSolarRadiation_sa("", "", 输出总辐射要素, "0", "45", "200", "MultiDays 2021 5 160", "14", "0.5", "NOINTERVAL", "1", "FROM_DEM", "32", "8", "8", "UNIFORM_SKY", "0.3", "0.5", 输出直接辐射要素, 输出散射辐射要素, 输出直接辐射持续时间要素)
7、密度分析
# Process: 核密度分析
arcpy.gp.KernelDensity_sa("", "", 输出栅格, "", "", "SQUARE_MAP_UNITS", "DENSITIES", "PLANAR")
# Process: 点密度分析
arcpy.gp.PointDensity_sa("", "", 输出栅格__2_, "", "Circle 0 MAP", "SQUARE_MAP_UNITS")
# Process: 线密度分析
arcpy.gp.LineDensity_sa("", "", 输出栅格__3_, "", "", "SQUARE_MAP_UNITS")
8、局部分析
# Process: 像元统计数据
arcpy.gp.CellStatistics_sa("", 输出栅格, "MEAN", "DATA")
# Process: 合并
arcpy.gp.Combine_sa("", 输出栅格__2_)
# Process: 大于频数
arcpy.gp.GreaterThanFrequency_sa("", "", 输出栅格__3_)
# Process: 小于频数
arcpy.gp.LessThanFrequency_sa("", "", 输出栅格__4_)
# Process: 最低位置
arcpy.gp.LowestPosition_sa("", 输出栅格__5_)
# Process: 最高位置
arcpy.gp.HighestPosition_sa("", 输出栅格__6_)
# Process: 等于频数
arcpy.gp.EqualToFrequency_sa("", "", 输出栅格__7_)
# Process: 等级
arcpy.gp.Rank_sa("", "", 输出栅格__8_)
# Process: 频数取值
arcpy.gp.Popularity_sa("", "", 输出栅格__9_)
9、影像分割和分类
# Process: Mean shift 影像分割
arcpy.gp.SegmentMeanShift_sa("", 输出栅格数据集, "15.5", "15", "20", "")
# Process: 从种子点生成训练样本
arcpy.gp.GenerateTrainingSamplesFromSeedPoints_sa("", "", 输出训练样本要素类, "30", "50")
# Process: 分类栅格
arcpy.gp.ClassifyRaster_sa("", "", 输出分类的栅格数据, "")
# Process: 创建精度评估点
arcpy.gp.CreateAccuracyAssessmentPoints_sa("", 输出精度评估点, "CLASSIFIED", "500", "STRATIFIED_RANDOM")
# Process: 导出深度学习的训练数据
arcpy.gp.ExportTrainingDataForDeepLearning_sa("", 输出文件夹, "", "TIFF", "256", "256", "128", "128", "ONLY_TILES_WITH_FEATURES", "KITTI_rectangles", "0", "", "0")
# Process: 更新精度评估点
arcpy.gp.UpdateAccuracyAssessmentPoints_sa("", "", 输出精度评估点__2_, "CLASSIFIED")
# Process: 检查训练样本
arcpy.gp.InspectTrainingSamples_sa("", "", "", 输出训练样本要素类_含分数_, 输出误分类栅格, "")
# Process: 移除栅格影像分割块伪影
arcpy.gp.RemoveRasterSegmentTilingArtifacts_sa("", 输出栅格数据集__2_, "512", "512")
# Process: 计算分割影像属性
arcpy.gp.ComputeSegmentAttributes_sa("", 输出段索引栅格, "", "COLOR;MEAN")
# Process: 计算混淆矩阵
arcpy.gp.ComputeConfusionMatrix_sa("", 输出混淆矩阵)
# Process: 训练 ISO 聚类分类器
arcpy.gp.TrainIsoClusterClassifier_sa("", "", 输出分类程序定义文件, "", "20", "20", "10", "COLOR;MEAN", "5", "0.5")
# Process: 训练支持向量机分类器
arcpy.gp.TrainSupportVectorMachineClassifier_sa("", "", 输出分类程序定义文件__2_, "", "500", "COLOR;MEAN")
# Process: 训练最大似然法分类器
arcpy.gp.TrainMaximumLikelihoodClassifier_sa("", "", 输出分类程序定义文件__3_, "", "COLOR;MEAN")
# Process: 训练随机树分类器
arcpy.gp.TrainRandomTreesClassifier_sa("", "", 输出分类器定义文件, "", "50", "30", "1000", "COLOR;MEAN")
10、提取分析
# Process: 值提取至点
arcpy.gp.ExtractValuesToPoints_sa("", "", 输出点要素, "NONE", "VALUE_ONLY")
# Process: 多值提取至点
arcpy.gp.ExtractMultiValuesToPoints_sa("", "", "NONE")
# Process: 按圆提取
arcpy.gp.ExtractByCircle_sa("", "", "", 输出栅格, "INSIDE")
# Process: 按多边形提取
arcpy.gp.ExtractByPolygon_sa("", "", 输出栅格__2_, "INSIDE")
# Process: 按属性提取
arcpy.gp.ExtractByAttributes_sa("", "", 输出栅格__3_)
# Process: 按掩膜提取
arcpy.gp.ExtractByMask_sa("", "", 输出栅格__4_)
# Process: 按点提取
arcpy.gp.ExtractByPoints_sa("", "", 输出栅格__5_, "INSIDE")
# Process: 按矩形提取
arcpy.gp.ExtractByRectangle_sa("", "DEFAULT", 输出栅格__6_, "INSIDE")
# Process: 采样
arcpy.gp.Sample_sa("", "", 输出表, "NEAREST", "", "CURRENT_SLICE")
11、插值分析
# Process: 克里金法
arcpy.gp.Kriging_sa("", "", 输出表面栅格, "None #", "", "VARIABLE 12", 输出预测栅格数据的方差)
# Process: 反距离权重法
arcpy.gp.Idw_sa("", "", 输出栅格, "", "2", "VARIABLE 12", "")
# Process: 含障碍的样条函数
arcpy.gp.SplineWithBarriers_sa("", "", "", "", 输出栅格__2_, "0")
# Process: 地形转栅格
arcpy.gp.TopoToRaster_sa("", 输出表面栅格__2_, "", "DEFAULT", "20", "", "", "ENFORCE", "CONTOUR", "20", "", "1", "0", "2.5", "100", 输出河流折线要素, 输出其余汇点要素, 输出诊断文件, 输出参数文件, "", 输出残差点要素, 输出河流和悬崖错误点要素, 输出等值线错误点要素)
# Process: 样条函数法
arcpy.gp.Spline_sa("", "", 输出栅格__3_, "", "REGULARIZED", "0.1", "12")
# Process: 自然邻域法
arcpy.gp.NaturalNeighbor_sa("", "", 输出栅格__4_, "")
# Process: 趋势面法
arcpy.gp.Trend_sa("", "", 输出栅格__5_, "", "1", "LINEAR", 输出_RMS_文件)
# Process: 通过文件实现地形转栅格
arcpy.gp.TopoToRasterByFile_sa("", 输出表面栅格__3_, 输出河流折线要素__2_, 输出其余汇点要素__2_, 输出残差点要素__2_, 输出河流和悬崖错误点要素__2_, 输出等值线错误点要素__2_)
12、数学分析
13、条件分析
# Process: 条件函数
arcpy.gp.Con_sa("", "", 输出栅格, "", "")
# Process: 设为空函数
arcpy.gp.SetNull_sa("", "", 输出栅格__2_, "")
# Process: 选取函数
arcpy.gp.Pick_sa("", "", 输出栅格__3_)
14、栅格创建
# Process: 创建常量栅格
arcpy.gp.CreateConstantRaster_sa(输出栅格, "", "INTEGER", "1", "0 0 250 250")
# Process: 创建正态栅格
arcpy.gp.CreateNormalRaster_sa(输出栅格__2_, "1", "0 0 250 250")
# Process: 创建随机栅格
arcpy.gp.CreateRandomRaster_sa(输出栅格__3_, "", "1", "0 0 250 250")
15、栅格综合
# Process: Nibble
arcpy.gp.Nibble_sa("", "", 输出栅格, "ALL_VALUES", "PRESERVE_NODATA", "")
# Process: 众数滤波
arcpy.gp.MajorityFilter_sa("", 输出栅格__2_, "FOUR", "MAJORITY")
# Process: 区域合并
arcpy.gp.RegionGroup_sa("", 输出栅格__3_, "FOUR", "WITHIN", "ADD_LINK", "")
# Process: 收缩
arcpy.gp.Shrink_sa("", 输出栅格__4_, "", "")
# Process: 散度
arcpy.gp.Expand_sa("", 输出栅格__5_, "", "")
# Process: 细化
arcpy.gp.Thin_sa("", 输出栅格__6_, "ZERO", "NO_FILTER", "ROUND", "")
# Process: 聚合
arcpy.gp.Aggregate_sa("", 输出栅格__7_, "", "SUM", "EXPAND", "DATA")
# Process: 边界清理
arcpy.gp.BoundaryClean_sa("", 输出栅格__8_, "NO_SORT", "TWO_WAY")
16、水文分析
# Process: 填洼
arcpy.gp.Fill_sa("", 输出表面栅格, "")
# Process: 捕捉倾泻点
arcpy.gp.SnapPourPoint_sa("", "", 输出栅格, "0", "")
# Process: 栅格河网矢量化
arcpy.gp.StreamToFeature_sa("", "", 输出折线要素, "SIMPLIFY")
# Process: 水流长度
arcpy.gp.FlowLength_sa("", 输出栅格__2_, "DOWNSTREAM", "")
# Process: 汇
arcpy.gp.Sink_sa("", 输出栅格__3_)
# Process: 河流链接
arcpy.gp.StreamLink_sa("", "", 输出栅格__4_)
# Process: 河网分级
arcpy.gp.StreamOrder_sa("", "", 输出栅格__5_, "STRAHLER")
# Process: 流动距离
arcpy.gp.FlowDistance_sa("", "", 输出栅格__6_, "", "VERTICAL", "D8", "MINIMUM")
# Process: 流向
arcpy.gp.FlowDirection_sa("", 输出流向栅格数据, "NORMAL", 输出下降率栅格数据, "D8")
# Process: 流量
arcpy.gp.FlowAccumulation_sa("", 输出蓄积栅格数据, "", "FLOAT", "D8")
# Process: 盆域分析
arcpy.gp.Basin_sa("", 输出栅格__7_)
# Process: 集水区
arcpy.gp.Watershed_sa("", "", 输出栅格__8_, "")
17、表面分析
# Process: 可见性
arcpy.gp.Visibility_sa("", "", 输出栅格, 输出地平面以上的栅格, "FREQUENCY", "ZERO", "1", "FLAT_EARTH", "0.13", "", "", "", "", "", "", "", "", "")
# Process: 含障碍的等值线
arcpy.gp.ContourWithBarriers_sa("", 输出等值线要素, "", "POLYLINES", "", "NO_EXPLICIT_VALUES_ONLY", "0", "", "0", "", "1")
# Process: 坡向
arcpy.gp.Aspect_sa("", 输出栅格__2_, "PLANAR", "METER")
# Process: 坡度
arcpy.gp.Slope_sa("", 输出栅格__3_, "DEGREE", "1", "PLANAR", "METER")
# Process: 填挖方
arcpy.gp.CutFill_sa("", "", 输出栅格__4_, "1")
# Process: 山体阴影
arcpy.gp.HillShade_sa("", 输出栅格__5_, "315", "45", "NO_SHADOWS", "1")
# Process: 曲率
arcpy.gp.Curvature_sa("", 输出曲率栅格, "1", 输出剖面曲线栅格, 输出平面曲线栅格)
# Process: 等值线
arcpy.gp.Contour_sa("", 输出要素类, "", "0", "1", "CONTOUR", "")
# Process: 等值线列表
arcpy.gp.ContourList_sa("", 输出折线要素, "")
# Process: 视域
arcpy.gp.Viewshed_sa("", "", 输出栅格__6_, "1", "FLAT_EARTH", "0.13", 输出地平面以上的栅格__2_)
# Process: 视域 2
arcpy.gp.Viewshed2_sa("", "", 输出栅格__7_, 输出地平面以上的栅格__3_, "FREQUENCY", "0 Meters", 输出观察点_区域关系表, "0.13", "0 Meters", "", "1 Meters", "", "GROUND", "", "GROUND", "0", "360", "90", "-90", "ALL_SIGHTLINES")
# Process: 视点分析
arcpy.gp.ObserverPoints_sa("", "", 输出栅格__8_, "1", "FLAT_EARTH", "0.13", 输出地平面以上的栅格__4_)
18、距离
# Process: 廊道分析
arcpy.gp.Corridor_sa("", "", 输出栅格)
# Process: 成本分配
arcpy.gp.CostAllocation_sa("", "", 输出分配栅格数据, "", "", "", 输出距离栅格数据, 输出回溯链接栅格数据, "", "", "", "", "")
# Process: 成本回溯链接
arcpy.gp.CostBackLink_sa("", "", 输出回溯链接栅格数据__2_, "", 输出距离栅格数据__2_, "", "", "", "", "")
# Process: 成本距离
arcpy.gp.CostDistance_sa("", "", 输出距离栅格数据__3_, "", 输出回溯链接栅格数据__3_, "", "", "", "", "")
# Process: 成本路径
arcpy.gp.CostPath_sa("", "", "", 输出栅格__2_, "EACH_CELL", "", "INPUT_RANGE")
# Process: 成本路径折线
arcpy.gp.CostPathAsPolyline_sa("", "", "", 输出折线要素, "BEST_SINGLE", "", "INPUT_RANGE")
# Process: 成本连通性
arcpy.gp.CostConnectivity_sa("", "", 输出要素类, 相邻连接的输出要素类)
# Process: 欧氏分配
arcpy.gp.EucAllocation_sa("", 输出分配栅格数据__2_, "", "", "", "", 输出距离栅格数据__4_, 输出方向栅格数据, "PLANAR", "", 输出反向栅格)
# Process: 欧氏反向
arcpy.gp.EucBackDirection_sa("", 输出反向栅格__2_, "", "", "", "PLANAR")
# Process: 欧氏方向
arcpy.gp.EucDirection_sa("", 输出方向栅格数据__2_, "", "", 输出距离栅格数据__5_, "PLANAR", "", 输出反向栅格__3_)
# Process: 欧氏距离
arcpy.gp.EucDistance_sa("", 输出距离栅格数据__6_, "", "", 输出方向栅格数据__3_, "PLANAR", "", 输出反向栅格__4_)
# Process: 路径距离
arcpy.gp.PathDistance_sa("", 输出距离栅格数据__7_, "", "", "", "BINARY 1 45", "", "BINARY 1 -30 30", "", 输出回溯链接栅格数据__4_, "", "", "", "", "")
# Process: 路径距离分配
arcpy.gp.PathAllocation_sa("", 输出分配栅格数据__3_, "", "", "", "BINARY 1 45", "", "BINARY 1 -30 30", "", "", "", 输出距离栅格数据__8_, 输出回溯链接栅格数据__5_, "", "", "", "", "")
# Process: 路径距离回溯链接
arcpy.gp.PathBackLink_sa("", 输出回溯链接栅格数据__6_, "", "", "", "BINARY 1 45", "", "BINARY 1 -30 30", "", 输出距离栅格数据__9_, "", "", "", "", "")
19、邻域分析
# Process: 块统计
arcpy.gp.BlockStatistics_sa("", 输出栅格, "Rectangle 3 3 CELL", "MEAN", "DATA")
# Process: 滤波器
arcpy.gp.Filter_sa("", 输出栅格__2_, "LOW", "DATA")
# Process: 点统计
arcpy.gp.PointStatistics_sa("", "", 输出栅格__3_, "", "Rectangle 3 3 CELL", "MEAN")
# Process: 焦点流
arcpy.gp.FocalFlow_sa("", 输出栅格__4_, "0")
# Process: 焦点统计
arcpy.gp.FocalStatistics_sa("", 输出栅格__5_, "Rectangle 3 3 CELL", "MEAN", "DATA", "90")
# Process: 线统计
arcpy.gp.LineStatistics_sa("", "", 输出栅格__6_, "", "", "MEAN")
20、重分类
# Process: 使用 ASCII 文件重分类
arcpy.gp.ReclassByASCIIFile_sa("", "", 输出栅格, "DATA")
# Process: 使用表重分类
arcpy.gp.ReclassByTable_sa("", "", "", "", "", 输出栅格__2_, "DATA")
# Process: 分割
arcpy.gp.Slice_sa("", 输出栅格__3_, "", "EQUAL_INTERVAL", "1")
# Process: 按函数重设比例
arcpy.gp.RescaleByFunction_sa("", 输出栅格__4_, "MSSMALL # # # # # #", "1", "10")
# Process: 查找表
arcpy.gp.Lookup_sa("", "", 输出栅格__5_)
# Process: 重分类
arcpy.gp.Reclassify_sa("", "", "", 输出栅格__6_, "DATA")
箴言:因为这些东西是非常简单的。不要抱怨自己学不会,那是因为你没有足够用心。