26 lines
832 B
Python
26 lines
832 B
Python
import arcpy
|
||
import pandas as pd
|
||
|
||
|
||
def read_arcgis_table(table_path):
|
||
"""
|
||
将ArcGIS表格转换为Pandas DataFrame
|
||
:param table_path: ArcGIS表格路径
|
||
:return: Pandas DataFrame
|
||
表格字段全部转换为大写
|
||
面积字段AREA转换为亩,保留4位小数,存储在temp_area字段中
|
||
"""
|
||
array = arcpy.da.TableToNumPyArray(table_path, "*")
|
||
|
||
df = pd.DataFrame(array)
|
||
# df.to_csv(r"D:\工作\三普成果编制\出图数据\广西海城区\过程数据\酸化面积统计表\temp.csv")
|
||
|
||
df.columns = df.columns.str.upper()
|
||
df["temp_area"] = df["AREA"] * 0.0015
|
||
df["temp_area"] = df["temp_area"].round(4)
|
||
|
||
# 删除可能存在的OID字段(如果不需要)
|
||
if 'OID@' in df.columns:
|
||
df = df.drop('OID@', axis=1)
|
||
|
||
return df |