R sp: unit of area of Polygon

2019-07-28 19:26发布

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!

标签: r polygon area sp
2条回答
你好瞎i
2楼-- · 2019-07-28 19:38

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.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-07-28 19:49

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.

查看更多
登录 后发表回答