When you use the AsText() function on geometry objects in MSSQL Server 2008+ you get something like this:

"LINESTRING (8.8446177236171337 47.721989356913951, 8.844617919281065 47.721977134398223, 8.844589303417802 47.721976942728766, 8.84454742773029 47.7219801783058, 8.8445167302356325 47.721989634438941, ...)"

The precision of the coordinates is far to great to be useful (for me). For wgs84 coordinates the seventh decimal place is worth ~11 mm. After that, it gets more or less meaningless.

For my workflow I need to put a lot of WKT's in a Textfile. To reduce file size I would like to reduce the coordinate precision to six decimal places.

I could process the textfile and reduce precision in my backend (c#, entity framework) but that seems like a rather costly task.

Is there a clever way in MSSQL Server to create WKT from geometry objects with a defined number of decimal places?

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.

Browse other questions tagged or ask your own question.