I have one raster and a shapefile of points. I want to check them if they are in the same coordinate system by plotting them together on a map (like in a classical GIS), here the R script :
# raster first
library(raster)
setwd("P:/folder/")
my.raster <- raster("raster_1991.img")
# shapefile second
library(rgdal)
library(sp)
library(maptools)
setwd("P:/folder")
meteo.shp <- readShapePoints("meteo.shp")
# set up same coordinate system
coord.sys <- CRS("+init=epsg:2065")
proj4string(meteo.shp) <- coord.sys
proj4string(my.raster) <- coord.sys
# plot them in one map (window)
plot(meteo.shp)
plot(my.raster, bg = "transparent", add = TRUE)
I am able to read the data and plot them, but only separately. How can I make sure myself that the points - meteo stations - are exactly where they should be if I cannot check them on a map?
proj4string()
throw any warnings when you used it?summary(meteo.shp)
before assigning EPSG I getObject of class SpatialPointsDataFrame Coordinates: min max coords.x1 20.06176 20.28333 coords.x2 49.11886 49.26306 Is projected: NA proj4string : [NA]
proj4string(meteo.shp)
andproj4string(my.raster)
before setting them to coord.sys - do they both return NA?