[英]How Do I Calculate the Area of a Polygon in a MySQL Database When the Polygon's Points are Lat Longs?
How do I calculate the area of a polygon stored in a MySql database? 如何计算存储在MySql数据库中的多边形的面积? The polygons' points are lat longs.
多边形的点是拉特长。 So, degrees and minutes seem to be causing a problem.
因此,度和分钟似乎导致了问题。
I've tried: 我试过了:
SELECT AREA( my_polygon )
FROM `my_table`
WHERE name = 'Newport'
Because, the points are lat longs, I get weird results. 因为,积分是拉特长,我得到奇怪的结果。
(I'm not able to switch to Postgre). (我无法切换到Postgre)。 Is there a way to do this in MySQL?
有没有办法在MySQL中这样做? I'd like to get the results in sq. meters or sq. km or sq. miles-- any of these would be fine.
我希望得到平方米或平方公里或平方英里的结果 - 其中任何一个都没问题。
You've got to transform those lats and lons into a more appropriate coordinate system. 你必须将这些lats和lons转换为更合适的坐标系。
Since the earth is a sphere, you're talking about calculating an area in spherical coordinates. 由于地球是一个球体,你所说的是以球坐标计算一个面积。
The docs say that the MySQL "AREA" function takes a polygon as its input. 文档说MySQL “AREA”函数将多边形作为输入。 I would say that if you want area as something like square miles you should convert your lat/lon coordinates into equivalent surface (x, y) coordinates with the right units (eg, miles).
我想说如果你想要像平方英里这样的区域,你应该将你的纬度/经度坐标转换为等效的表面(x,y)坐标和正确的单位(例如,英里)。 Then pass those into the AREA function.
然后将它们传递给AREA功能。
This link suggests that someone else has had this problem and solved it. 此链接表明其他人遇到此问题并解决了该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.