Skip to content

vect() now silently assigns a CRS to some data frames #1985

@AMBarbosa

Description

@AMBarbosa

Hi,

According to ?vect, the crs argument should be empty by default, and it used to be. But now, in some cases a CRS is automatically assigned to non-spatial inputs (e.g. data frames), without any message or warning:

fer <- geodata::sp_occurrence("Alytes", "muletensis")

class(fer)
# "data.frame"

fer_sv <- terra::vect(fer)

crs(fer_sv, proj = TRUE)
# "+proj=longlat +datum=WGS84 +no_defs" -- where did this come from?


quakes <- read.csv("https://data.humdata.org/dataset/4881d82b-ba63-4515-b748-c364f3d05b42/resource/10ac8776-5141-494b-b3cd-bf7764b2f964/download/earthquakes1970-2014.csv")

quakes_sv <- terra::vect(quakes)

crs(quakes_sv)
# ""

Is this desired? In any case, I think it's not documented, and it would grant at least a message in the console output. The user may not wish (and not expect) for the SpatVector to get a CRS, and WGS84 may not be the right datum for all lon-lat coordinates.

Cheers,

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