Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surface area of the earth #2490

Open
mtennekes opened this issue Dec 14, 2024 · 3 comments
Open

Surface area of the earth #2490

mtennekes opened this issue Dec 14, 2024 · 3 comments

Comments

@mtennekes
Copy link
Contributor

Trying to find out the surface area of the earth:

sf::FULL_bbox_ |> st_as_sfc() |> st_area()

returns 0

@tim-salabim
Copy link
Member

tim-salabim commented Dec 14, 2024

For me this gives

> library(sf)
Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
> sf::FULL_bbox_ |> st_as_sfc() |> st_area()
5.100661e+14 [m^2]

with sf_use_s2(FALSE)

> sf_use_s2(F)
Spherical geometry (s2) switched off
> sf::FULL_bbox_ |> st_as_sfc() |> st_area()
0 [m^2]

@mtennekes mtennekes changed the title Surface are of the earth Surface area of the earth Dec 14, 2024
@edzer
Copy link
Member

edzer commented Dec 14, 2024

And

> sf_use_s2(TRUE); sf::FULL_bbox_ |> st_as_sfc() |> st_set_crs(NA) |> st_area()
Spherical geometry (s2) switched on
[1] 0
> sf_use_s2(FALSE); sf::FULL_bbox_ |> st_as_sfc() |> st_set_crs(NA) |> st_area()
Spherical geometry (s2) switched off
[1] 64800

which, I guess, should be an error for the first case: POLYGON FULL does not have an equivalence in R2 (NA crs)

edzer added a commit that referenced this issue Dec 14, 2024
@edzer
Copy link
Member

edzer commented Dec 14, 2024

Gives (order reversed)

library(sf)
# Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.4.0; sf_use_s2() is TRUE
sf_use_s2(FALSE); sf::FULL_bbox_ |> st_as_sfc() |> st_set_crs(NA) |> st_area()
# Spherical geometry (s2) switched off
# [1] 64800
sf_use_s2(TRUE); sf::FULL_bbox_ |> st_as_sfc() |> st_set_crs(NA)
# Spherical geometry (s2) switched on
# Error in `st_crs<-.sfc`(`*tmp*`, value = value) : 
#   To set the crs to NA, first remove the full polygons; see: st_is_full()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants