Files
ArcGis_Py/tools/core/utils/arcgis_utils.py
2026-04-22 12:27:49 +08:00

26 lines
832 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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