VAST
VAST copied to clipboard
Using class for extrapolation-grid and derived quantities
I'm starting to scope out whether I should start using an R package and defined class for inputs (i.e., extrapolation-grid) and outputs (e.g., predicted density, linear predictors, etc). I'll start taking notes on this thread, and feel free to chime in with opinions, suggestions, and perhaps simple code examples.
First, I'm looking at package sp
and class SpatialPointsDataFrame
; It looks like it includes utilities for projection using package rgdal
and CRS system, which is helpful (although I think rgdal
has some issues across OS). SpatialPixelDataFrame
also might be useful but its hard to tell.
I've used some of the sp
objects in e.g. my change of support example. They provide a nice way of structuring spatial data, but can be unwieldy at times. For example, to create a SpatialPolygon
from a set of coordinates, you need to create a Polygon
object, then use it to make a Polygons
object, and finally turn that into a SpatialPolygons
object. This is of course easier with predefined polygons, and I think that shapefiles would be imported as SpatialPolygons
directly.
A newer option to check out is the sf
package, which is written by many of the same authors as sp
and follows the Simple Features standard. I haven't used it much but it looks more approachable than sp
. It also has easier ggplot
integration (though sp
objects can be used in ggplot
as well after fortify
ing them). The new Geocomputation with R book looks like a nice resource on manipulating spatial data with the sf
package.
I think that the GDAL
, GEOS
and PROJ4
dependencies from these packages are sort of inevitable if you're dealing with spatial data. I'm not aware of better libraries for changing projections etc. The sf
README has straightforward instructions for how to install these packages. The only OS that doesn't need anything special is Windows.
Yes, functions in the raster package are great (and work with SpatialPoints / SpatialPointsDataFrame objects), and I'd keep things working with sp or sf objects. It seems like the bigger decision is whether you want the output to be compatible with tibbles. I don't know of cross-platform issues...
Yeah, PBSmapping
does not involve any cross-platform issues for projections, but only does UTM and not CRS. Hence the development path I originally tool. I think its time to revisit ;)