3

I just started using gdal. I'm trying to get longitude and latitudes from pictures. This is what I have so far. This gives me an attribute error. Anyone know how to fix the attribute error?

 from osgeo import osr
 import numpy
 import gdal
 ds = gdal.Open(r"path")
 prj = ds.GetProjectionRef()
 oldcs = osr.SpatialReference()
 oldcs.ImportfromWkt(prj)

Error:

---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-1-b32399e41073> in <module>
 7 prj = ds.GetProjectionRef()
 8 oldcs = osr.SpatialReference()
----> 9 oldcs.ImportfromWkt(prj)
D:\Anaconda\lib\site-packages\osgeo\osr.py in <lambda>(self, name)
 354 __setattr__ = lambda self, name, value: _swig_setattr(self, SpatialReference, name, value)
 355 __swig_getmethods__ = {}
--> 356 __getattr__ = lambda self, name: _swig_getattr(self, SpatialReference, name)
 357 __repr__ = _swig_repr
 358 
D:\Anaconda\lib\site-packages\osgeo\osr.py in _swig_getattr(self, class_type, name)
 78 if method:
 79 return method(self)
---> 80 raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
 81 
 82 
AttributeError: 'SpatialReference' object has no attribute 'ImportfromWkt'
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jul 13, 2020 at 2:20

1 Answer 1

4

You have a typo. The method is ImportFromWkt() (note the capitalized F).

oldcs.ImportFromWkt(prj)

It is a good idea to use an IDE that offers autocomplete features so you can easily avoid this type of mistakes in the future as well as check all the methods that a specific object can call.

answered Jul 13, 2020 at 3:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.