How to open a geopackage file

Hi there!

Currently I'm trying to correctly open a geopackage file, I've put the link below.

The internet says using the rgdal package is necessary to open a gpkg file. I have installed the package but I don't know how to use it. Please keep in mind I'm a complete newby to R who just got familiar with the interface and syntax of the software. If there's someone who can help me out that would be much appreciated!

Cheers,

1 Like

I think you can use the sf package to read those data

url <- "https://zenodo.org/record/3386198/files/pc_to_resilience.gpkg?download=1"
temp_file <- tempfile(fileext = ".gpkg")
download.file(url, destfile = temp_file, mode = "wb")

library(sf)
data <- st_read(temp_file)

Several resources to help

There also a book on sf https://keen-swartz-3146c4.netlify.com/intro.html#reading

and another one on geocomputation

1 Like

Thank you for your reply!

Unfortuantely the code you send me didn't work to load the gpkg file, online I have read I need to use the rgdl package?

Since packages alone were already a bit confusing to me I decided to start with some of those introductory lessons you send me to learn about spatial datasets and its characteristics. They're of great help!

I manage to read it using sf
I guess it is because I have all the suggest dependencies installed already. See
https://cran.r-project.org/web/packages/sf/index.html

If you installed those it could work I guess.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.