计算红宝石中多边形的面积 [英] calculate the area of a polygon in ruby

查看:99
本文介绍了计算红宝石中多边形的面积的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个纬度/经度坐标对数组,它们代表一个多边形。我正在尝试确定该多边形内的总面积。我将如何在Ruby中进行操作?

I have an array of latitude/longitude coordinate pairs that represent a polygon. I'm trying to determine the total area within that polygon. How would I go about doing that in Ruby?

以下是多边形的示例数组:

Here's an example array of the polygon:

[[37.7663613767094, -122.452969210084], [37.7674219449606, -122.444718340349], [37.7701838510542, -122.445330289514], [37.7709974013834, -122.439159589248], [37.7700761930893, -122.438861402472], [37.7703501163684, -122.436868738421], [37.7712650571321, -122.437078116573], [37.7736056746515, -122.437533130227], [37.7714671036087, -122.453964210266], [37.7663613767094, -122.452969210084]]


推荐答案

您可以使用包装GEOS的库(C地理空间库本身是JTS的端口)。
https://github.com/dark-panda/ffi-geos

You can use this library which wraps GEOS (a C geospatial library itself a port of the JTS). https://github.com/dark-panda/ffi-geos

该库可以处理坐标空间中的计算并处理近似值。

This library can handle the calculations in coordinate space and takes care of the approximations.

取决于多少您需要的准确性我会先将数据投影到适当的投影(而不是Mercator)。然后计算您的面积

Depending on how much accuracy you need I would project the data first to an appropriate projection (not Mercator). Then calculate your area

这篇关于计算红宝石中多边形的面积的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆