0

Background

In R, I have downloaded two datasets using the following commands (slighlty modificed from https://mgimond.github.io/Spatial/point-pattern-analysis-in-r.html):

library(maptools)
z <- gzcon(url("http://colby.edu/~mgimond/Spatial/Data/starbucks.rds"))
location <- readRDS(z)

z <- gzcon(url("http://colby.edu/~mgimond/Spatial/Data/ma.rds"))
citylimits <- readRDS(z)

The first is of class SpatialPointsDataframe, while the second is of class SpatialPolygonsDataFrame. I have also downloaded a SpatialGridDataFrame, which I have converted to a RasterLayer:

z <- gzcon(url("http://colby.edu/~mgimond/Spatial/Data/pop_sqmile.rds"))
popdensity <- readRDS(z)
popdensity <-raster::raster(popdensity)

Problem

Depending on the way in which (in RStudio) I resize the plot panel, it seems that the raster layer doesn't match the rest of the data (see attached images).

Question

Is that an RStudio issue, or is it an issue regarding the coordinate system of the layers? As for the latter, I have checked the CRS and the three are listed below (along with other info). I do not understand whether the raster layers' coord.ref exactly matches that of the two other layers. Is what described caused by different coord. ref. embedded in the layers?

popdensity

class       : RasterLayer 
dimensions  : 308, 598, 184184  (nrow, ncol, ncell)
resolution  : 500, 500  (x, y)
extent      : 623157.2, 922157.2, 4602709, 4756709  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=18 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
data source : in memory
names       : band1 
values      : 5.9, 61572.7  (min, max)

locations

class       : SpatialPointsDataFrame 
features    : 171 
extent      : 648032.3, 917740.7, 4609785, 4748107  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=18 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0

citylimits

class       : SpatialPolygonsDataFrame 
features    : 1 
extent      : 623157.2, 921923.8, 4602709, 4756659  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=18 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0
variables   : 4

enter image description here enter image description here

  • 1
    Just reissue the plot commands to the new canvas size and everything will be aligned again. This is just a quirk of the graphic device when resized. – Jeffrey Evans Apr 3 '18 at 7:57
  • Thanks for your input. My impression was that there was something wrong with the coord. systems. I wish this does not sound as a new question, but why the RasterLayer is actually missing the reference to NAD83 that is featuring the other two layers instead? Is NAD83 equivalent to the "ellps=GRS80" statement featuring the RasterLayer? – NewAtGis Apr 3 '18 at 8:22

Your Answer

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

Browse other questions tagged or ask your own question.