Created
March 6, 2023 21:48
-
-
Save brownag/f11acd8b6870d0ca406aa57a1dc9fcfe to your computer and use it in GitHub Desktop.
reprex for bug in files with multiple layers and SRS in terra (gpkg example)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(terra) | |
gdal(lib = "") | |
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 expected | |
a <- vect("test.gpkg") | |
a | |
plot(a) | |
# CRS is wrong (matches first layer) | |
b <- vect("test.gpkg", layer = "test2") | |
b | |
plot(b) | |
# inspect gpkg contents SRS | |
con <- DBI::dbConnect(RSQLite::SQLite(), "test.gpkg") | |
DBI::dbGetQuery(con, "SELECT * FROM gpkg_contents") | |
DBI::dbGetQuery(con, "SELECT * FROM gpkg_spatial_ref_sys") | |
DBI::dbDisconnect(con) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment