Rick Reeves
2007-Sep-20 17:32 UTC
[R] Superimposing vector polygons over raster grid in a plot
Hello: I would like to superimpose vector polygons (state outlines) from a Shape file on top of a satellite image, imported into a SpatialGridDataFrame from GEOTIFF via gdal_translate and readGDAL. When I plot polygon and point shape files in R, into SpatialPointDataFrame and SpatialPolygonDataFrame, the two feature sets line up geographically, so it seems logical that a SpatialGridDataFrame should behave in the same way. From my initial research, the spplot function is the correct function for plotting grids/images with axes and annotation. The big question is, how do I incorporate a Spatial(Points or Polygons)DataFrame into the spplot display list? It seems as though many scientists would like to create such plots without resorting to GRASS or another GIS. Thanks for any advice, Rick Reeves Rick Reeves Scientific Programmer / Analyst National Center for Ecological Analysis and Synthesis UC Santa Barbara reeves at nceas.ucsb.edu www.nceas.ucsb.edu 805 892 2533
Dylan Beaudette
2007-Sep-20 19:20 UTC
[R] Superimposing vector polygons over raster grid in a plot
On Thursday 20 September 2007, Rick Reeves wrote:> Hello: > > I would like to superimpose vector polygons (state outlines) from a > Shape file on top of a satellite image, > imported into a SpatialGridDataFrame from GEOTIFF via gdal_translate and > readGDAL. > > When I plot polygon and point shape files in R, into > SpatialPointDataFrame and SpatialPolygonDataFrame, > the two feature sets line up geographically, so it seems logical that a > SpatialGridDataFrame should behave > in the same way. > > From my initial research, the spplot function is the correct function > for plotting grids/images with axes and > annotation. > > The big question is, how do I incorporate a Spatial(Points or > Polygons)DataFrame into the spplot display list? > > It seems as though many scientists would like to create such plots > without resorting to GRASS or > another GIS.While GRASS and GMT are excellent tools, here are some ideas on how to make composite maps in R: http://casoilresource.lawr.ucdavis.edu/drupal/node/442 cheers, Dylan> Thanks for any advice, > Rick Reeves > > Rick Reeves > Scientific Programmer / Analyst > National Center for Ecological Analysis and Synthesis > UC Santa Barbara > reeves at nceas.ucsb.edu > www.nceas.ucsb.edu > 805 892 2533-- Dylan Beaudette Soils and Biogeochemistry Graduate Group University of California at Davis 530.754.7341
Dylan Beaudette
2007-Sep-20 22:31 UTC
[R] Superimposing vector polygons over raster grid in a plot
On Thursday 20 September 2007, Rick Reeves wrote:> Thanks for this, Dylan. Great example. One question: 'elev.pred' and > 'elev.var' are columns in the result 'p' from predict? > thanks, RRHi, elev.pred and elev.var are the 'zcol' attribute, or rather the value at each cell within the spatial dataframe object 'p' in that example. here is the construct for spplot() ... note that i left off the 'zcol=' bit on the first call to spplot... i will fix that. spplot(p, zcol='elev.var', ... cheers, Dylan> Dylan Beaudette wrote: > > On Thursday 20 September 2007, Rick Reeves wrote: > >> Hello: > >> > >> I would like to superimpose vector polygons (state outlines) from a > >> Shape file on top of a satellite image, > >> imported into a SpatialGridDataFrame from GEOTIFF via gdal_translate and > >> readGDAL. > >> > >> When I plot polygon and point shape files in R, into > >> SpatialPointDataFrame and SpatialPolygonDataFrame, > >> the two feature sets line up geographically, so it seems logical that a > >> SpatialGridDataFrame should behave > >> in the same way. > >> > >> From my initial research, the spplot function is the correct function > >> for plotting grids/images with axes and > >> annotation. > >> > >> The big question is, how do I incorporate a Spatial(Points or > >> Polygons)DataFrame into the spplot display list? > >> > >> It seems as though many scientists would like to create such plots > >> without resorting to GRASS or > >> another GIS. > > > > While GRASS and GMT are excellent tools, here are some ideas on how to > > make composite maps in R: > > > > http://casoilresource.lawr.ucdavis.edu/drupal/node/442 > > > > cheers, > > > > Dylan > > > >> Thanks for any advice, > >> Rick Reeves > >> > >> Rick Reeves > >> Scientific Programmer / Analyst > >> National Center for Ecological Analysis and Synthesis > >> UC Santa Barbara > >> reeves at nceas.ucsb.edu > >> www.nceas.ucsb.edu > >> 805 892 2533-- Dylan Beaudette Soils and Biogeochemistry Graduate Group University of California at Davis 530.754.7341