Giter VIP home page Giter VIP logo

Comments (5)

PMassicotte avatar PMassicotte commented on June 29, 2024

I am also getting the same results. I am asking around for some pointer and I will get back to you.

from rnaturalearth.

PMassicotte avatar PMassicotte commented on June 29, 2024

Does this work for you?

Basically, I am creating points regularly spaced over your area. Then, I project these points into your coord system and remove points that are out of view (NAs). Finally, I create a convex hull and use it to crop world before the projection.

library(tidyverse)
library(rnaturalearth)
library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.8.3, PROJ 9.1.1; sf_use_s2() is TRUE
library(s2)

proj <- "+proj=geos +h=35785831.0 +lat_0=45 +lon_0=-90.476194 +sweep=y"

world <- ne_countries(
  continent = c("north america", "south america"),
  scale = "medium",
  returnclass = "sf"
)

pts <- world |>
  # st_bbox() |>
  st_sample(size = 2e3, method = "regular") |>
  st_transform(proj)

ch <- pts[!st_is_empty(pts), drop = FALSE] |>
  s2_convex_hull() |>
  st_as_sf() |>
  st_transform(st_crs(world))

world2 <- world |>
  st_crop(ch)
#> Warning: attribute variables are assumed to be spatially constant throughout
#> all geometries

worldGeos <- st_transform(world2, crs = proj)

ggplot(data = worldGeos) +
  geom_sf(color = "lightgray", fill = "lightgray") +
  ggtitle("Geostationary Satellite View")

Created on 2024-02-12 with reprex v2.1.0

from rnaturalearth.

TeresaPegan avatar TeresaPegan commented on June 29, 2024

That does indeed work for me, thank you!
I think it makes sense to leave the issue open for now, since the underlying bug remains?

from rnaturalearth.

PMassicotte avatar PMassicotte commented on June 29, 2024

I am not sure if it is a bug of sf or the underlying implementation. Tagging @edzer just in case this is related to sf.

from rnaturalearth.

PMassicotte avatar PMassicotte commented on June 29, 2024

Much simpler solution (credit to @mdsumner)

library(ggplot2)
library(rnaturalearth)
library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.8.0, PROJ 9.2.0; sf_use_s2() is TRUE

world <- ne_countries(
  continent = c("north america", "south america"),
  scale = "medium",
  returnclass = "sf"
)

world <- st_cast(world, "POLYGON")
#> Warning in st_cast.sf(world, "POLYGON"): repeating attributes for all
#> sub-geometries for which they may not be constant

worldGeos <- st_transform(
  world,
  crs = "+proj=geos +h=35785831.0 +lat_0=45 +lon_0=-90.476194 +sweep=y"
)
ggplot(data = worldGeos) +
  geom_sf(color = "lightgray", fill = "lightgray") +
  ggtitle("Geostationary Satellite View")

Created on 2024-02-12 with reprex v2.1.0

from rnaturalearth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.