Reputation: 13
I am trying to count the surface (STArea ()
) of a geometry saved as a WKT, but I get the wrong value.
I mention that using geography did not help. I also noticed, that in Postgis area is counted properly when I set use_spheroid=false.
DECLARE @g geometry = geometry::STGeomFromText('POLYGON((21.5601775022348 52.1813862660549,21.5601461469143 52.1813295549141,21.559853091877 52.1813993365177,21.5597665803865 52.1812613330339,21.5593037698201 52.1813692515792,21.5592677194965 52.1813021172669,21.5592607711581 52.1813034375092,21.5592188506351 52.1812334620465,21.5591248909245 52.1812561912586,21.5590395906618 52.1811137531269,21.5587491625113 52.1811808662478,21.5589985172752 52.1816470941761,21.5595646783963 52.1815219107667,21.5601775022348 52.1813862660549))', 4326);
select @g;
select @g.STArea()
Upvotes: 0
Views: 834
Reputation: 88996
In geography, the left hand side is the interior as you traverse the polygon. So you have specified the inverse of the polygon you want. With geometry it doesn't matter, as the interior is always the the bounded area.
Try
DECLARE @g geography = geography::STGeomFromText('POLYGON((21.5601775022348 52.1813862660549,21.5601461469143 52.1813295549141,21.559853091877 52.1813993365177,21.5597665803865 52.1812613330339,21.5593037698201 52.1813692515792,21.5592677194965 52.1813021172669,21.5592607711581 52.1813034375092,21.5592188506351 52.1812334620465,21.5591248909245 52.1812561912586,21.5590395906618 52.1811137531269,21.5587491625113 52.1811808662478,21.5589985172752 52.1816470941761,21.5595646783963 52.1815219107667,21.5601775022348 52.1813862660549))', 4326);
set @g = @g.ReorientObject()
select @g, @g.STArea()
outputs
2381.30781687796
Upvotes: 1