1 Star 0 Fork 8

baocx/Landslide_Analysis

forked from Luoge/Landslide_Analysis 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
util_export_factor_names.py 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
Luoge 提交于 2018-05-10 11:55 . 1. 增强属性表导出csv
# -*- coding: utf-8 -*-
"""
批量导出滑坡因子文件至
"""
import pandas as pd
import arcpy
if __name__ == "__main__":
# arcgis工具箱模式
year = arcpy.GetParameter(0)
saved_dir = arcpy.GetParameterAsText(1)
saved_slope_settings_filename = "{0}\\slopeSettings_{1}.csv".format(saved_dir, year)
# 代码模式
# arcpy.env.workspace = "G:/DataForDoctorPaper/博士论文数据.gdb"
# year = 2010
# saved_slope_settings_filename = "./settings/slopeSettings.csv"
static_rasters = arcpy.ListDatasets("Factor_*", "Raster")
cd_rasters = arcpy.ListDatasets("Change*", "Raster")
current_cd_raster = None
for nn in cd_rasters:
if year == int(nn[-4:]):
current_cd_raster = nn
break
landuse_raster = "LU_{0}".format(year)
rain_raster = "Rain_{0}".format(year)
roadbuffer_raster = "RoadBuffer_{0}".format(year)
ndvi_raster = "NDVI_{0}".format(year)
yLabel_raster = "y_isLandslide_{0}".format(year)
factor_list = static_rasters.copy()
factor_list.append(current_cd_raster)
factor_list.append(landuse_raster)
factor_list.append(rain_raster)
factor_list.append(roadbuffer_raster)
factor_list.append(ndvi_raster)
factor_list.append(yLabel_raster)
df = pd.DataFrame(factor_list)
df.columns = ['factors']
# print(df.columns)
df.to_csv(saved_slope_settings_filename, encoding="gb2312", index=False)
arcpy.AddMessage("Save file '{0}' successful!".format(saved_slope_settings_filename))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/baocx/Landslide_Analysis.git
git@gitee.com:baocx/Landslide_Analysis.git
baocx
Landslide_Analysis
Landslide_Analysis
master

搜索帮助