mysql-ST_Area()用于纬度和经度

我有一个包含MariaDB中多个坐标的多边形:

POLYGON((50.4668 -6.90665,51.73607 0.14657,55.3032 -4.52724,50.4668 -6.90665))

我想像这样用MariaDB计算该多边形的面积:

SELECT ST_Area(ST_GeomFromText('POLYGON((50.4668 -6.90665,51.73607 0.14657,55.3032 -4.52724,50.4668 -6.90665))'))

上面的查询结果是15.546039738650009,这是错误的.我使用this工具计算了多边形的面积,得出119116192747.1.

如何使mariaDB理解此多边形包含经度和纬度以正确计算面积?

解决方法:

根据MariaDB文件,它不提供此功能:

In MariaDB, the SRID value is just an integer associated with the geometry value. All calculations are done assuming Euclidean (planar) geometry.

但是,在Mysql 8.0.13中提供了此功能,您可以使用ST_Area()计算多边形面积:

Incompatible Change: Previously, ST_Area() supported only geometry arguments having a Cartesian spatial reference system (SRS) and produced an error when invoked with geometry arguments that specified a geographic SRS. ST_Area() now supports geometry arguments having a geographic SRS and returns the geodetic area in square meters.

因此,如果您将数据库更改为MYSQL> 8.0.13您可以使用以下查询计算多边形面积:

SELECT ST_Area(ST_PolyFromText('POLYGON((50.4668 -6.90665,51.73607 0.14657,55.3032 -4.52724,50.4668 -6.90665))', 4326));

相关文章

安装开始...1.打开“https://dev.mysql.com/downloadsepo/yu...
安装Helm3#官网下载慢#wgethttps://get.helm.sh/helm-v3.5.4...
通过Linux命令行启动用的指令:systemctlstartmariadb.servi...
InstallingMariaDBServer10.4TodeployMariaDBCommunityServe...
阅读目录一什么是存储引擎二mysql支持的存储引擎三使用存储引...
1、安装MariaDB安装命令yum-yinstallmariadbmariadb-server安...