【发布时间】:2016-04-21 04:10:30
【问题描述】:
我需要替换属性表中一列的值(将名为“label”的列中的零替换为 100)。这可能使用 ogr 或 python 吗?我必须为 500 多个 shapefile 执行此操作。
【问题讨论】:
标签: python gdal shapefile arcpy ogr
我需要替换属性表中一列的值(将名为“label”的列中的零替换为 100)。这可能使用 ogr 或 python 吗?我必须为 500 多个 shapefile 执行此操作。
【问题讨论】:
标签: python gdal shapefile arcpy ogr
在 Esri ArcGIS 领域中,Update Cursors 通常用于此类操作。
例如
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)
【讨论】: