user2330778
user2330778

Reputation: 235

readOGR {rgdal} taking too long to execute

I am trying to execute the readOGR function for a shapefile but it is taking way too long to process and I end up killing the process after 20mins or so. Following is the code:

country <- readOGR('shapeFiles','gadm28', encoding = 'UTF-8')

The execution hangs after printing the following lines:

OGR data source with driver: ESRI Shapefile 
Source: "shapeFiles", layer: "gadm28"
with 255272 features
It has 61 fields

I am working on Windows 7 with 8GB RAM, using RStudio. Any suggestions on what I could change to get it running quick?

Upvotes: 4

Views: 1291

Answers (1)

Bastien
Bastien

Reputation: 3098

How big is your shape? Some large shape can take forever to load in R. I think waiting 20 minutes isn't long enough.

My suggestion, call it before lunch, wait. Then when it succeed, save your object into a RDATA.

save(country, file="country.rdata")

Loading the RDATA is faster than the shp itself.

Upvotes: 1

Related Questions