我对GDAL库非常陌生(实际上从今天起就开始尝试),我很难弄清楚我在这里做错了什么。我正试图从GDAL执行“接近度”函数,但不断获取“str”对象不可调用”错误消息。 谁能告诉我我做错了什么
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
在第三行代码中,您将
gdal_proximity
设置为以下字符串然后尝试将其作为函数调用
这会触发错误,因为它不是函数,它是字符串,所以不能作为函数调用
相关问题 更多 >
编程相关推荐