I have a 1 km by 1 km grid polygons for all of Ontario, Canada. This file is roughly 1 GB with 1116965 rows and can downloaded here: https://www.ontario.ca/data/utm-universal-transverse-mercator-1-km-grid

When I read it into R using:

grid1 <- readOGR(dsn="C:\\Users\\Desktop\\Data", layer="1KM_GRID",encoding="utf-8")

It will print the console a few things and then my computer freezes, at a certain point it goes black and won't respond to any keyboard commands leaving me to force restart my computer.

I need this grid shapefile to later perform an spThin on it and I'd prefer to stay in R. My computer has 8GB of RAM and I'm running Windows 10 64-bit.

Is there a different package in R that deals with large spatial data such as ff for data.frames? Or are there settings I can change in R that will allow me to work with this data?

  • That's classic R behaviour for running out of RAM. Can you load the file with a computer with more memory and simplify it? Check out rmapshaper::ms_simplify()
    – Phil
    Nov 25, 2016 at 11:38
  • @Phil Thanks, we do have a server computer that I may try next week. Oddly enough it opens in ArcMap okay. I don't know if I can simplify it as they're just grid shapes.
    – GISHuman
    Nov 25, 2016 at 17:25
  • 1
    The only thing I can suggest it try your server, do your spThin analysis on that, and save out the results as an RData file to load onto other computers?
    – Phil
    Nov 26, 2016 at 11:34


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.