RGeo 및 Geojson으로 면적 계산 (Calculating area with RGeo and Geojson)


문제 설명

RGeo 및 Geojson으로 면적 계산 (Calculating area with RGeo and Geojson)

geojson에 다중 다각형이 정의되어 있습니다. 면적을 계산하려고 합니다.

표면적 코드 경로를 통과할 때 매우 혼란스러운 결과를 얻습니다. 일부 요소를 잘못 사용하고 있기 때문인 것 같습니다.

boundaries = {...valid geojson...}
field_feature_collection = RGeo::GeoJSON.decode(boundaries, geo_factory: RGeo::Geographic.simple_mercator_factory)
first_feature = field_feature_collection[0]
first_feature.geometry.area
# => 1034773.6727743163 

내 기능의 면적이 ~602982제곱미터라는 것을 알고 있습니다. 나는 그것을 위의 결과와 어떻게 조화시킬 수 있는지 알아낼 수 없습니다.

나는 명백한 예측을 놓치고 있는 것 같습니다.

무엇이 잘못되었는지 아는 사람이 있습니까?


참조 솔루션

방법 1:

This is most likely due to using the simple_mercator_factory as your geo_factory in the GeoJSON decoder. The simple_mercator_factory parses geometries from lon/lat coordinate systems but performs all of the calculations (length, area, etc.) using the Mercator projection (EPSG:3857) of the geometry.

The Mercator projection gets more distorted the further away you get from the equator, so that's why the area you're getting is about double what you expect it to be.

Depending on the scope of your project, it may be more appropriate to use a different projection, especially if area is a key metric for you. If you choose a different projection, the rgeo‑proj4 gem has just been updated to work with newer versions of PROJ, so you can create the appropriate transformations in your app.

Another option is to use the RGeo::Geographic.spherical_factory which uses a spherical approximation for the earth and will give you more realistic areas than the Mercator projection, but it is slower than using GEOS backed cartesian factories (which is what the simple_mercator_factory uses).

(by earnoldKeith Doggett)

참조 문서

  1. Calculating area with RGeo and Geojson (CC BY‑SA 2.5/3.0/4.0)

#geojson #rgeo






관련 질문

Geodjango GeoJSON 직렬 변환기 기하학은 항상 'null'입니다. (Geodjango GeoJSON Serializer geometry always 'null')

전단지에서 레이어 켜기/끄기(더 복잡한 시나리오) (Toggle layers on and off in Leaflet (more complex scenario))

RethinkDB r.polygon() - GeoJSON LinearRing에는 최소 4개의 위치가 있어야 합니까? (RethinkDB r.polygon() - GeoJSON LinearRing must have at least four positions?)

Leaflet : GeoJSON 속성에서 GeoJSON 레이어 설정 아이콘 (Leaflet : setting icon for GeoJSON layer from GeoJSON property)

'GeoJsonLayer' 기호를 확인할 수 없습니다. (Cannot resolve symbol 'GeoJsonLayer ')

스키마의 mongoose geojson, "지역 키를 추출할 수 없습니다" 오류 (mongoose geojson in schema, "Can't extract geo keys" error)

Android Google 지도는 GeoJSON을 사용하여 마커를 설정합니다. (Android Google Maps set marker using GeoJSON)

GraphQl로 geojson 포인트를 쿼리하는 방법은 무엇입니까? (How to query a geojson point with GraphQl?)

geojson 포인트 데이터 마커가 전단지 맵에서 클러스터링되지 않습니다. (The geojson point data markers are not clustering in leaflet map)

전단지 geoJSON.onEachFeature는 함수가 아닌가요? (leaflet geoJSON.onEachFeature is not a function?)

Folium에서 특정 국가 강조 표시 (Highlight one specific country in Folium)

RGeo 및 Geojson으로 면적 계산 (Calculating area with RGeo and Geojson)







코멘트