【发布时间】:2020-03-16 21:20:06
【问题描述】:
我对 GDAL 库非常陌生(实际上从今天开始尝试),我很难弄清楚我在这里做错了什么。我正在尝试从 GDAL 执行 'proximity' 函数,但不断收到 ''str' object is not callable' 错误消息。 谁能指出我做错了什么。
import os
from osgeo import gdal, osr
gdal_proximity = "C:\\anaconda3\\envs\\geo_py37\\Scripts\\gdal_proximity.py"
proximityInput = gdal.Open(folderPath + os.sep + "proximity_input.tif")
outputTemplate = gdal.Open(folderPath + os.sep + "output_template.tif")
######## Raster properties based on 'outputTemplate' ################
projection = outputTemplate.GetProjection()
ncols = outputTemplate.RasterXSize
nrows = outputTemplate.RasterYSize
bandCount = outputTemplate.RasterCount
upx, xres, xskew, upy, yskew, yres = outputTemplate.GetGeoTransform()
#####################################################################
driver = gdal.GetDriverByName('Gtiff')
proximityOutput = driver.Create(folderPath + os.sep + "proximity_output.tif", ncols, nrows, bandCount, gdal.GDT_Float32)
proximityOutput.SetGeoTransform([upx, xres, xskew, upy, yskew, yres])
proximityOutputPrj = distanceRaster.SetProjection(projection)
gdal_proximity (proximityInput, proximityOutputPrj)
追溯:
Traceback (most recent call last):
File "C:/Users/antoi/.PyCharmCE2019.3/config/scratches/Radial_Linear_Mean.py", line 22, in <module>
gdal_proximity(proximityInput, proximityOutputPrj)
TypeError: 'str' object is not callable
【问题讨论】:
-
“继续获取 ''str' object is not callable' 错误消息。”:Edit 你的问题并显示 完整回溯