String input or Unicode is not recognized as WKT EWKT and HEXEWKB

This might be an easy problem, but I don't seem to understand it. I use GeoDjango, and I have the latitude and longitude that I converted to strings (see My_lat and my_long).

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

String input or unicode unrecognized as WKT EWKT and HEXEWKB

My code is:

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)') 

To make sure that the variables my_lat and my_long have the correct data, I printed them out and they show these values: 30.751277 for my_lat and -101.25 for my_long.

If I simply enter the following values: mypoint = fromstr ('POINT (-101.25 30.751277)') there are no errors, but obviously I need to use variables to transfer data.

Any ideas? Thanks!

+4
source share
1 answer

This line is interpreted literally:

 fromstr('POINT(my_long_lat)') 

Try

 fromstr('POINT(' + my_long_lat + ')') 
+9
source

Source: https://habr.com/ru/post/1336629/


All Articles