4

I have installed the "GeoCoding" plugin in QGIS and it worked well even though I have used non-ASCII characters to geocode (i.e. Hacettepe Üniversitesi). However, when I tried to do the same in PyQGIS with the following code I got the error: "UnicodeEncodeError: 'ascii' codec can't encode character". The problem is that the returned address contains non-ASCII characters. Any ideas to solve this?

from geopy.geocoders import Nominatim
#Next, we'll create our geocoder:
geocoder = Nominatim()
#geocode an address:
location = geocoder.geocode("Hacettepe Üniversitesi")
print location

Another relevant question: I rely on Joel Lawhead's book ('QGIS Python Programming Cookbook') and the import statement relevant to this example in the book is: "from GeoCoding.geopy.geocoders import Nominatim". However, this statement gave the following error "ImportError: No module named geopy.geocoders". Is there a source we could follow to make these import statements without a try-and-guess?

  • Received a similar error even if I input London Eye! :S – banbar Jul 29 '17 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.