I have a geographic polygon created as follows
DECLARE @polyString as varchar(max);
SET @polyString = 'POLYGON((' + @eastAsString + ' ' + @northAsString +',' + @westAsString + ' ' + @northAsString + ',' + @westAsString + ' '+@southAsString +','+ @eastAsString + ' ' + @southAsString +',' +@eastAsString +' ' +@northAsString +'))';
DECLARE @g geography;
SET @g = geography::STPolyFromText(@polyString, 4326)
I would like to find the centre lat/long of the polygon? Is this possible inside sql server?
You can use the
EnvelopeCenter()method of thegeographytype.It would be helpful to define what exactly you mean by center of the polygon, because there are different ways of defining it.