开发者

Spatial querying, converting metres to radians?

I have geographic data that was loaded into the geography datatype. For very specific purposes, I now need to have store this as a geometry. However, I need to perform a query like this.开发者_StackOverflow中文版

DECLARE @radius INT -- e.g. 3000 metres

DECLARE @geo geometry -- my starting shape

SET @geo = @geo.STBuffer(@radius) -- this obviously doesnt work.. 

SELECT Geo FROM GeometryTable 
WHERE Geo.STWithin (@geo) = 1


Meters are a measure of length while radians are a measure of an angle so i don't think you can.

Are you trying to calculate an arc length?

Take a look at the links below:

  • http://wiki.answers.com/Q/How_do_you_convert_radians_to_meters
  • http://www.regentsprep.org/Regents/math/algtrig/ATM1/arclengthlesson.htm


This trick might work, if someone can validate this technique or provide a better alternative then they'll get the accepted answer.

Basically, I am thinking I can use the STBuffer of a geography which will apply the correct radius in metres around my geographical shape and then I convert back to a geometry. As the shapes were loaded originally as geography all the points are the same. This shape-flip should give me a resulting geometry with a pretty accurate buffer around it.

DECLARE @radius INT -- e.g. 3000 metres

DECLARE @geo geometry -- my starting shape

SET @geo = GEOMETRY::STGeomFromWKB(GEOGRAPHY::STGeomFromWKB(@geo.STAsBinary(),
           4326).STBuffer(@radius).STAsBinary(),4326)

SELECT Geo FROM GeometryTable 
WHERE Geo.STWithin (@geo) = 1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜