2

I have a list of points (with latitude and longitude) in an SQL Server database, and for each of these points I have to generate a 50 x 50 degrees square (the point being the South West angle of the square).

For instance, if I have the point 0,0 I create the polygon with the following SQL query:

SELECT geography::STPolyFromText('POLYGON((0 0, 50 0, 50 50, 0 50, 0 0))', 4326)

I expected that any point with a latitude greater than 50 would not be part of the polygon generated above. But if I check if the point 25,52 is within the polygon, the query returns true

SELECT geography::STPolyFromText('POLYGON((0 0, 50 0, 50 50, 0 50, 0 0))', 4326).STIntersects(geography::STPointFromText('POINT(25 52)', 4326)) -> true

The reason is because when I display the polygon, the shape is rounded at the top:

The 50x50 polygon

In this case, how can I generate a geographic polygon where the upper edge is straight and follow the 50th parallel? Should I use another projection?

Also Geometry data type is not an option for this project, I need to stick to Geography.

1
  • 3
    A "square" on the globe isn't square. Your chosen datatype does not allow simple Cartesian operation.
    – Vince
    Commented May 28, 2021 at 3:26

1 Answer 1

0

You can approximate it with regular Polygon, but you need to add a lot of points along the parallel to reduce error.

Or you can use CURVEPOLYGON with CIRCULARSTRING that follows exactly the parallel (but might be slower and less portable to other systems).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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