[R-sig-Geo] How to read .gpkg (Geopackage) files in R

Michael Sumner mdsumner at gmail.com
Fri Aug 26 00:40:36 CEST 2016


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]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list