How to read shapefiles from Google Drive or any other free repository

Hello!

I´ve just finished a flexdashboard which includes some leaflet maps showing data on migratory bird species distribution and wind farms, beside other layers of interest. I’m trying to host it on github, but I’m facing problems due to the large size of the geoespatial files. So I thougt that perhaps I could keep the large data files in a free repository and read them using some avaliable package.

I used de 'gsheet' package to read part of my data in .xlsx file format and it did work.

 install.packages('gsheet')  
library(gsheet) 

data <- gsheet2tbl('https://drive.google.com/open?id=1tgvOoEMkHRgNTVuHdlO3DikH0cEGsL0X')

View(data)

But I found no way of reading the files in .shp format from the Google Drive.

Anybody with some tips or ideas on how I could solve the problem?

Thanks in advance for any help!

SHP files are rather inefficient; consider storing their content already "digested" in rds format instead.

readRDS will take an url() for file argument; you may need / want to add open = 'rb' to specify binary read (instead of text).

Ok... I´ll look for more information on RDS file format, since I'm not familiar with it.
Thanks a lot!

The rds format is used to save any single R object - have a look at the official documentation R: Serialization Interface for Single Objects
It is very helpful for saving intermediary results between sessions, or for sharing with other users. It can be used with remote objects (url's) and uses compression, so it is usually preferable (bandwith wise) to sharing raw files such as shapefiles or what not...

1 Like