You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed this first when other folks were having problems using ESRI File GeoDatabases and vect() that at first I could not reproduce.
Upon closer inspection I found the offending GDBs contained multiple vector layers with different spatial reference systems--one geographic and one projected in case it is relevant.
It appears that there is either an assumption the spatial reference is constant for all layers or only the first SRS is used? I am pretty sure that e.g. GDB and GPKG support multiple SRS. Here is a reproducible example involving a GeoPackage with two layers and two SRS:
library(terra)
#> terra 1.7.19
gdal(lib="")
#> gdal proj geos #> "3.5.2" "8.2.1" "3.9.3"
data(us_states, package="spData")
x<- vect(us_states)[1,]
y<- project(x, "EPSG:5070")
writeVector(x, "test.gpkg")
writeVector(y, "test.gpkg", layer="test2", insert=TRUE)
# CRS is as expecteda<- vect("test.gpkg")
#> Warning: [vect] Reading layer: test#> Other layers: test2a#> class : SpatVector #> geometry : polygons #> dimensions : 1, 6 (geometries, attributes)#> extent : -88.47323, -84.89184, 30.24971, 35.00803 (xmin, xmax, ymin, ymax)#> source : test.gpkg#> coord. ref. : lon/lat NAD83 (EPSG:4269) #> names : GEOID NAME REGION AREA total_pop_10 total_pop_15#> type : <chr> <chr> <chr> <chr> <num> <num>#> values : 01 Alabama South 133709.272642372 4.713e+06 4.831e+06
plot(a)
# CRS is wrong (matches first layer)b<- vect("test.gpkg", layer="test2")
b#> class : SpatVector #> geometry : polygons #> dimensions : 1, 6 (geometries, attributes)#> extent : 704900.9, 1044769, 832261.6, 1376504 (xmin, xmax, ymin, ymax)#> source : test.gpkg (test2)#> coord. ref. : lon/lat NAD83 (EPSG:4269) #> names : GEOID NAME REGION AREA total_pop_10 total_pop_15#> type : <chr> <chr> <chr> <chr> <num> <num>#> values : 01 Alabama South 133709.272642372 4.713e+06 4.831e+06
plot(b)
#> Warning: [is.lonlat] coordinates are out of range for lon/lat
I noticed this first when other folks were having problems using ESRI File GeoDatabases and
vect()
that at first I could not reproduce.Upon closer inspection I found the offending GDBs contained multiple vector layers with different spatial reference systems--one geographic and one projected in case it is relevant.
It appears that there is either an assumption the spatial reference is constant for all layers or only the first SRS is used? I am pretty sure that e.g. GDB and GPKG support multiple SRS. Here is a reproducible example involving a GeoPackage with two layers and two SRS:
The text was updated successfully, but these errors were encountered: