I have a table with geometries, all with about 13 digits of accuracy. While trying to represent them with ST_AsText though, most vertices come out in decimal notation, but some come out in scientific notation. Problem is, I'm extracting these geometries in a python script and parsing them to arrays through regular expression, and the e- notation is screwing this up.

This does not happen frequently, but once is enough to halt the entire process (or more precisely, generate incorrect results for the remainder of the geometry). I have tried truncating the coordinate values to less digits, but it matters not, the same vertices get modified by some reason. ST_AsEWKT turns up the same problem, as expected.

Why is this happening? Any solutions I could use to either solve this problem or work around it?

up vote 4 down vote accepted

Try to update your script and use ST_AsGeoJSON().
You can also choose the number of digits with this function.

http://postgis.net/docs/ST_AsGeoJSON.html

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.