On Fri, 26 Aug 2016 at 07:18 Manuel Sp?nola <mspinola10 at gmail.com> wrote:
Dear list members,
How can I read a .gpkg (Geopackage) file in R?
You're in luck because it's extremely easy.
library(rgdal)
layers <- ogrListLayers("parcelas.gpkg")
## you may have more than one layer
x <- readOGR("parcelas.gpkg", layers[1])
## some kind of *DataFrame
print(class(x))
plot(x)
Cheers, Mike.
Read on only if you're interested in more details about GeoPackage.
Geopackage is also extremely extensible since it's built right on top of
SQLite. If you are keen, you can investigate the contents with
dplyr/RSQLite - though there's no need if sp/rgdal does what you want:
library(dplyr)
library(RSQLite)
db <- src_sql("parcelas.gpkg")
print(db) ## what tabes are in there?
tbl_df(db, "some_table_name")
The geometry is in one of the tables in WKB form, so it's not "tables all
the way down" but still pretty useful.
The name of my file is: parcelas.gpkg
Best,
--
*Manuel Sp?nola, Ph.D.*
Instituto Internacional en Conservaci?n y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspinola at una.cr <mspinola at una.ac.cr>
mspinola10 at gmail.com
Tel?fono: (506) 8706 - 4662
Personal website: Lobito de r?o <https://sites.google.com/
site/lobitoderio/>
Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>
[[alternative HTML version deleted]]