【发布时间】:2023-01-05 20:40:18
【问题描述】:
我正在尝试使用 JoinField 将包含数百万行的 csv 文件加入到 shapefile 中,但这需要很长时间。连接完成后,连接字段的所有行都为 0。我还尝试将字典与 UpdateCursor 一起使用,但没有发生连接。有一个更好的方法吗?
我使用的 JoinField 代码是:
arcpy.MakeFeatureLayer_management("mukey.shp", "mapunit")
arcpy.CopyRows_management(kvalues_path, "kvalues") #to give the table OIDs
arcpy.JoinField_management("mapunit", "mukey", "kvalues", "mukey", "ksat_mday")
“mukey”是 csv 文件和 shapefile 之间的公共字段,而“ksat_mday”是我想加入到 shapefile 的字段。
我使用的带有 UpdateCursor 代码的字典用于替换连接两个要素类的连接。可能是代码不起作用,因为我将一个 csv 文件加入到一个 shapefile 而不是两个要素类。代码取自https://community.esri.com/t5/python-blog/turbo-charging-data-manipulation-with-python/ba-p/884079。
【问题讨论】:
-
你想尝试使用 pandas merge 代替吗?>> stackoverflow.com/a/69866971/12128167
标签: python arcgis dictionary-comprehension arcpy arcmap