Rize S. answered 03/23/23
Master's in MISM, 25 yrs Exp: SQL Specialist
The error message suggests that your input geometry is invalid, which is preventing it from being converted to geography. The error message also suggests using the MakeValid method to fix any invalid geometry, but it seems like you are already doing that in your query.
Without seeing the actual LineString, it's difficult to diagnose the issue. However, here are a few things you could try:
- Check if the input geometry is valid: You can use the STIsValid() method to check if the geometry is valid. If it returns false, then the geometry is invalid and needs to be fixed using the MakeValid method.
- Simplify the LineString: If the LineString is very long, it could be causing the error. Try simplifying it using the STSimplify() method before converting it to geography.
- Try a different conversion method: Instead of using the STGeomFromText() method, try using the STGeomFromWKB() method to convert the geometry to geography.
- Split the LineString into smaller segments: If the LineString is too long, try splitting it into smaller segments using the STLineSubstring() method and then convert each segment to geography separately.
Regarding sharing the LineString, you can store it in a file or a database table and provide a link or instructions on how to access it.