I have a data.frame consisting of a points with an associated continuos value and their X,Y coordinates. Altough it's not stored anywhere it's projection is a Lambert conformal conic. I think this is why when I try to make it a raster object:

rast <- raster(dataframe)

I get the following error:

Error en .local(x, ...) : data are not on a regular grid

How can I tackle this issue? Thank you.

  • 2
    Based on other questions, I think this function required a regular grid of points, just as the error message reports--the coordinate system has nothing to do with it. If your data isn't regular, you need a function that can interpolate the data into a regular grid. See gis.stackexchange.com/questions/35039/… – mkennedy Apr 16 '13 at 19:37
  • I think my confusion si what exactly is a regular grid of points. Could you explain this to me? for example, if the points are all equally spaced but you have "missing points" would the grid become irregular? – JEquihua Apr 16 '13 at 20:52
  • Yes, you understand. For any missing point, the function has to decide what the z value should be. It could just be set to "no data", but usually you interpolate to make a smooth grid. I don't know R, so I can't give you a good answer, just some comments! – mkennedy Apr 16 '13 at 20:56

This particular function does require a regularly spaced set of points. The error message is reporting that there are gaps in your data and it's not able to interpolate between the existing points to provide the value for the missing points.

You need to see if R has a different rasterizing function that will interpolate to fill in the gaps, or find some other way to convert your data to a regular grid.

| improve this answer | |
  • 1
    +1. I'm LOL at the second paragraph, though: R probably has hundreds of ways to interpolate data. – whuber Apr 17 '13 at 19:46
  • Good point; I'll clarify, although I wouldn't have bothered to add this answer if JEquihua hadn't said to. – mkennedy Apr 17 '13 at 19:48
  • I wasn't intending to sound critical--I just thought the phrasing was amusing in how it appeared to suggest that R might possibly not have such a function. That's not the fundamental issue, though. For someone who until a few hours ago was unaware that data had to be interpolated onto rasters, it is far more important to learn how to select an interpolation method appropriate for their data and their investigation objectives. It's not just a matter of finding some generic interpolation package and applying it. – whuber Apr 17 '13 at 19:53
  • I have been exploring the interpolation of point data for sometime now. In fact you have answered some of my questions @whuber, thanks. It's just that what I do in R I usually just end up opening in Qgis and continue working it from there. I am looking for ways to do this directly in R. I was in fact just trying to turn my point data to a raster to plot it using the raster package. I'm quite new to GIS and all spatial topics so sorry for sounding so lost sometimes. – JEquihua Apr 17 '13 at 20:04
  • Actually now I'm intrigued as to why my grid has holes in it... How would I go on to verify where the holes are? – JEquihua Apr 17 '13 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.