R sp: unit of area of Polygon

柔情痞子 提交于 2019-12-12 18:34:45

问题


I use R to read in a shape file to analyse with the sp package polygons of oilfields (longitude-latitude with WGS84) and their respective areas. Unfortunately I do not know the unit of the area output. E.g. the area output is on average 0.85 units (max 4.34) which probably is not in square kilometers since this would be much too small for oilfields.

Does anyone know the unit of the area output of Polygons in the sp package? Many thanks!


回答1:


To get a correct area computation for a polygon in lat-lon coordinates, it would be better to convert them to a metric equal-area projection using "spTransform" beforehand. Alternatively, you could use package geosphere which allows to do

"Spherical trigonometry for geographic applications. That is, compute distances and re- lated measures for angular (longitude/latitude) locations"

For example, this:

require(geosphere)
areaPolygon(mypoly)

(with mypoly being a spatialPolygons object) will give you its area in square kilometers.

HTH.




回答2:


When using sf, you actually get the resulting units:

> library(sf)
Linking to GEOS 3.5.1, GDAL 2.1.3, proj.4 4.9.2, lwgeom 2.3.2 r15302
> demo(nc, ask = FALSE, echo = FALSE)
Reading layer `nc.gpkg' from data source `/home/edzer/R/x86_64-pc-linux-gnu-library/3.4/sf/gpkg/nc.gpkg' using driver `GPKG'
converted into: MULTIPOLYGON
Simple feature collection with 100 features and 14 fields
Attribute-geometry relationship: 0 constant, 8 aggregate, 6 identity
geometry type:  MULTIPOLYGON
dimension:      XY
bbox:           xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
epsg (SRID):    4267
proj4string:    +proj=longlat +datum=NAD27 +no_defs
> st_area(nc[1:2,])
Units: m^2
[1] 1137388604  611077263
> units::set_units(st_area(nc[1:2,]), km^2)
Units: km^2
[1] 1137.3886  611.0773

For longlat data, as here, it uses geosphere behind the scenes.



来源:https://stackoverflow.com/questions/44302234/r-sp-unit-of-area-of-polygon

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!