Skip to content

st_wrap_dateline: extent #541

@rsbivand

Description

@rsbivand

In this thread, I provide an sp/maptools/rgdal resolution to horizontal lines in:

library(maps)
map('world',, projection='mollweide')

as:

library(maps)
wrld <- map("world", fill=TRUE, plot=FALSE)
library(sp)
library(maptools)
ID <- sapply(strsplit(wrld$names, ":"), "[", 1L)
wrld_sp <- map2SpatialPolygons(wrld, ID=ID)
proj4string(wrld_sp) <- "+proj=longlat +datum=WGS84"
wrld_sp1 <- nowrapSpatialPolygons(wrld_sp, offset=180)
library(rgdal)
wrld_moll <- spTransform(wrld_sp1, CRS("+proj=moll"))
plot(wrld_moll)

Trying an sf variety, I see:

library(sf)
wrld <- st_as_sf(maps::map("world", fill=TRUE, plot=FALSE))
st_bbox(wrld)
wrld_wrap <- st_wrap_dateline(wrld, options = "WRAPDATELINE=YES", quiet = FALSE)
# options:        WRAPDATELINE=YES 
# Error in CPL_wrap_dateline(x, options, quiet) : 
#  Expecting a single value: [extent=0].

Is this because xmax > 180 in:

st_bbox(wrld)
#      xmin       ymin       xmax       ymax 
#-180.00000  -85.19218  190.27084   83.59961 

and reading the original ticket.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions