Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String or unicode input unrecognized as WKT EWKT, and HEXEWKB

It might be a easy problem but I don't seem to figure it out. I'm using GeoDjango and I have a latitude and a longitude that I converted into strings (see my_lat and my_long).

For some reason it doesn't like the my_long_lat variable when I use it inside the fromstr('POINT(my_long_lat)') and I get this error:

String or unicode input unrecognized as WKT EWKT, and HEXEWKB

My code:

my_lat = str(lat)[1:10]
my_long = str(long)[21:31]
my_long_lat = my_long + " " + my_lat
mypoint = fromstr('POINT(my_long_lat)')

Just to make sure the variables my_lat and my_long have the right data I printed them and they show these values: 30.751277 for my_lat and -101.25 for my_long.

If I just type the values like this: mypoint = fromstr('POINT(-101.25 30.751277)') there are no errors generated but evidently I need to use variables to pass the data in.

Any ideas? Thank you!

like image 403
avatar Avatar asked Jan 22 '11 21:01

avatar


1 Answers

This line is being interpreted literally:

fromstr('POINT(my_long_lat)')

Try

fromstr('POINT(' + my_long_lat + ')')
like image 135
Hamish Avatar answered Sep 30 '22 12:09

Hamish