2

我需要为一列替换属性表中的值(将名为“label”的列中的零替换为 100)。这可能使用 ogr 或 python 吗?我必须为 500 多个 shapefile 执行此操作。

4

1 回答 1

1

在 Esri ArcGIS 领域中,更新光标通常用于此类操作。

例如

import arcpy

# Your input feature class
fc = r'C:\path\to\your.gdb\feature_class'

# Start an update cursor and change values from 0 to 100 in a field called "your_field"
with arcpy.da.UpdateCursor(fc, "your_field") as cursor:
    for row in cursor:
        if row[0] == 0:
            row[0] = 100
        cursor.updateRow(row)
于 2016-02-14T05:53:52.020 回答