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

Generating polygon on re-centered Winkel-Tripel #2

Closed
MartinBeal opened this issue Nov 2, 2019 · 2 comments
Closed

Generating polygon on re-centered Winkel-Tripel #2

MartinBeal opened this issue Nov 2, 2019 · 2 comments

Comments

@MartinBeal
Copy link

Using this handy recenter function I am able to recenter global spatial SF data to any desired meridian.

However, it doesn't work with your solution for creating a background oceans polygon. When projecting the object to Winkel-Tripel it folds on itself.

Rplot

Any idea how to do this for 360 degree data?

`### My code
shift <- -152 # desired meridian shift

maxlong <- 180 + shift + 360 # shift 180 degrees to 360 degrees
minlong <- 180 + shift

longs <- c(rep(c(maxlong, minlong), each = 181), maxlong )

Your code

outline <-
list(cbind(longs, lats)) %>%
st_polygon() %>%
st_sfc( # create sf geometry list column
crs = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
) %>%
st_sf()

outline <- outline %>%
st_transform_proj(crs = crs_wintri) # transform to Winkel tripel

ggplot() +
geom_sf(
data = outline,
fill = "#56B4E950", color = "grey30", size = 0.5/.pt
) +
coord_sf(datum = NULL) +
theme_map()`

@clauswilke
Copy link
Collaborator

Please provide a complete reproducible example, prepared with the reprex package.

@MartinBeal
Copy link
Author

In fact, I later realized that the issue was merely to change the meridian in the projection with:

`
shift <- -152 # desired meridian shift
central_meridian <- 360 + shift

proj <- sprintf("+proj=wintri +datum=WGS84 +lon_0=%i +no_defs +over", central_meridian)
`

Sorry to bother you. Thanks for the link to the reprex vignette, I will read up on that and use it in the future.

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

2 participants