OSM, rgeos, osmar, area calculation, does not add up

I am trying to get the polygon size from OSM using osmar to load data. However, a health check tells me this is wrong.

Below is an example of what I mean.

(1) The geographical area around Hyde Park in London. Extract all the ways and relationships that are marked as “park.”

devtools::install_github('osmdatar/osmdata')
library(osmdata)
library(osmar)
library(sp)
library(sf)
library(rgeos)

osmO <- get_osm(center_bbox(-0.167919, 51.5072682, 2000, 2000))

ids_relations <- osmO$relations$tags[osmO$relations$tags$v=="park","id"]
ids_ways <- osmO$ways$tags[osmO$ways$tags$v=="park","id"]
ids_sub <- find_down(osmO, way(c(ids_relations, ids_ways)))
sp_sub_park <- as_sp(subset(osmO, ids = ids_sub), "polygons")

Now I want to know the area of ​​each of these "parks" [Fig1] (the largest in the middle is Hyde Park).

spplot(sp_sub_park, c("version"), colorkey = FALSE, col.regions=c('green'))

Fig. 1

There are two ways:

1) Use the 'area' slot in the polygon itself.

a1 <- sapply(sp_sub_park@polygons, function(x) x@area)

2) Calculate the area with the specified projection.

bg_poly_t <- spTransform(sp_sub_park, CRS("+proj=longlat +datum=WGS84"))
a2 <- rgeos::gArea(bg_poly_t, byid=TRUE)

These two give me the same result [Fig. 2] (note that the two largest areas are Hyde Park, divided into two expensive)

plot(a1*1000000, a2*1000000)

Fig2

, . ( ). - 300 , , (- ~ 1.420.000 ).

?

+4
2

"" lat/lon, , "" ( @Phil), (, geosphere).

, st_area sf geosphere, . :

sf_sub_park <- st_as_sf(sp_sub_park)
areas <- st_area(sf_sub_park)
sum(areas)

:

2551269 ^ 2

@Phil.

+1

, (WGS84, , , IDK?). 2,5 , ?

sp_sub_park <- spTransform(sp_sub_park, CRS("+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs "))
gArea(sp_sub_park)
# [1] 2550387

, ~ 1,4 , - (.. Kensington Gardens ?).

0

Source: https://habr.com/ru/post/1679276/


All Articles