NotImplementedError: Wrong number or type of arguments for overloaded function 'CoordinateTransformation_TransformPoint'

by intern12345   Last Updated August 13, 2019 20:22 PM

Hello I am new to working with GeoTiff data and I am trying to grab lat/lon values from a tiff image. Here is my code:

import gdal
import matplotlib.pyplot as plt
import osr

# open the dataset and get the geo transform matrix
ds = gdal.Open(r'C:\Users\_______\Documents\Landsat8\LC08_L1GT_156120_20170207_20170216_01_T2_B5.tif') 
xoffset, px_w, rot1, yoffset, rot2, px_h = ds.GetGeoTransform()

x = 100
y = 100

# supposing x and y are your pixel coordinate this 
# is how to get the coordinate in space.
posX = px_w * x + rot1 * y + xoffset
posY = rot2 * x + px_h * y + yoffset

# shift to the center of the pixel
posX += px_w / 2.0
posY += px_h / 2.0

# get CRS from dataset 
crs = osr.SpatialReference()
crs.ImportFromWkt(ds.GetProjectionRef())
# create lat/long crs with WGS84 datum
crsGeo = osr.SpatialReference()
crsGeo.ImportFromEPSG(4326) # 4326 is the EPSG id of lat/long crs 
t = osr.CoordinateTransformation(crs, crsGeo)
(lat, long, z) = t.TransformPoint(posX, posY)

However, when I run this I keep receiving the following error:

NotImplementedError: Wrong number or type of arguments for overloaded 
function 'CoordinateTransformation_TransformPoint'

I have no idea what this means, I have looked up the error and found no userful information so I am hoping one of you have experienced this problem before.



Related Questions


Updated May 16, 2019 17:22 PM

Updated September 12, 2018 19:22 PM

Updated November 28, 2018 04:22 AM

Updated July 03, 2019 10:22 AM

Updated March 13, 2019 12:22 PM