9

I have a dataset consisting of latitude-longitude pairs associated with some Z value (e.g. data regarding degree of plant vegetation coverage).

I'd like to perform some analyses on the spatial distribution of this data.

To do so, it will be necessary to bin proximal data points.

I would like to do this with a Discrete Global Grid such as an Icosahedron Snyder Equal Area (ISEA) grid, or the grid produced by DGGRID.

The key is that the latitude-longitude values of the data can be convertable into unique cell ids, that the latitude-longitude of the cell's center be determinable, the size of the cells be variable (for analysis at different spatial scales), and that the cells be of equal area to a close approximation.

An image depicting how this might look:

Discrete Global Grid

Is there anything in R which does this?

Richard
  • 56,349
  • 34
  • 180
  • 251

4 Answers4

5

I've just completed an R package called dggridR which wraps dggrid in an easy-to-use way.

The package is also available on CRAN.

dggridR: Discrete Global Grids for R

Richard
  • 56,349
  • 34
  • 180
  • 251
4

After searching high and low for exactly the same issue, I have ended up using DGGRID itself and R. DGGRID is excellent by the way. All the hard work has been done. It would be a major boon to the R community to have it implemented as a package (I hope Kevin Sahr is reading this).

Incidentally, that URL is out of date. I made the same mistake and ended up with an older version of DGGRID. The newest one, which is two versions further along, is at:

http://discreteglobalgrids.org/

  • I asked Sahr about this and he didn't seem to have plans, but said he'd appreciate it being done. I tried to write a thin wrapper myself, but it didn't transfer nicely between computers. I am going the Open GIS SWG on DGGs comes back with results soon. – Richard Aug 03 '15 at 16:13
  • I'm amazed this need isn't more widespread. There isn't an easy cross-platform pre-compiled tool to do what DGGRID does. Compiling it took a lot of trial and error, but once it was done, it worked flawlessly. – Dr Raveem Ismail Aug 03 '15 at 16:22
  • 1
    I've just finished an R package called [dggridR](https://github.com/r-barnes/dggridR) which wraps DGGRID and works on Linux, Mac, and Windows. It's available on Github now, but should soon be available on CAN. The packages handles compiling DGGRID, so it should be quite easy to use. – Richard Jul 12 '16 at 22:22
  • Running into a few little niggles with updating rgdal and sp from source. Does it really need the ultra new versions? – Dr Raveem Ismail Jul 15 '16 at 15:24
  • I think it probably does not require the ultra new versions. I just used what I knew worked from my own setup. If you'd like to test it with the older versions you have installed and let me know if it works, I'd appreciate it! – Richard Jul 15 '16 at 16:44
  • I've also updated the package a number of times in the last few days, so update to get the new functionality. Could you raise additional questions/issues on Github or email me about them (my email's in the package) to avoid spamming this comment space? – Richard Jul 15 '16 at 16:46
1

Why not use DGGRID itself, which can do everything you asked? For example, you could use DGGRID to transform a text file of lat/lon/datavalue records into records of the form cellID/datavalue, and then import those into R.

  • 2
    Because a great deal of data will be analyzed and the long/lat pairs are only two columns in otherwise large data frames. The possibility of mistakes in the export/import process is very real. It is best to contain as much of the analysis within R as possible. – Richard Aug 07 '12 at 19:08
  • 1
    I've just finished an R package called [dggridR](https://github.com/r-barnes/dggridR) which wraps DGGRID and works on Linux, Mac, and Windows. It's available on Github now, but should soon be available on CAN. The packages handles compiling DGGRID, so it should be quite easy to use. – Richard Jul 12 '16 at 22:23
1

There is only one other lead I ever turned up for hexagonal gridding over a curved surface: some untested/beta functions for the hexbin package:

http://ugrad.stat.ubc.ca/R/library/hexbin/html/00Index.html

  • (PS: As a matter of protocol, let me know if this should have been part of the original answer, or whether it constitutes a new one!) – Dr Raveem Ismail Aug 18 '15 at 15:33
  • Pretty sure this works fine as a separate answer, though they could also be combined. I think that's more a matter of style. – Richard Aug 18 '15 at 20:08