Skip to content

Will summary(new("SpatialPolygons")) really need sf? #125

Closed

Description

@bastistician
options(sp_evolution_status = 2)
library("sp")
prototype <- new("SpatialPolygons")
summary(prototype)
## Error in is.projected(p4str) : sf required for evolution_status==2L

str(prototype@proj4string)
## Formal class 'CRS' [package "sp"] with 1 slot
##   ..@ projargs: chr NA

is.projected(CRS())
## Error in is.projected(CRS()) : sf required for evolution_status==2L

This is because the trivial NA check in the current evolution-2 code of sp:::is.projectedCRS()

sp/R/projected.R

Lines 124 to 125 in fcc10c6

} else if (is.null(wkt2) && is.na(p4str))
as.logical(NA)

comes only after leveraging the "heavy" sf::st_is_longlat(obj).
Could the order be changed such that is.projected() for (legacy) Spatial objects with unknown CRS won't need sf?

( This is from experimenting with surveillance, which currently does not need rgdal, but with evolution 2 would unnecessarily load sf just to get a missing value from is.projected() for maps with unknown projection. )

Activity

  1. edzer commented on Dec 21, 2022

    @edzer
    Owner

    Makes total sense - thanks!

  2. added a commit that references this issue on Apr 30, 2024
    bf50789
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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