ASC files:
writeRaster(rcE, "path/to/my/folder/filename.asc", format="ascii")
don't store projections. Save as a GeoTIFF (.tif
) and you'll get a raster file with CRS in its metadata that will read correctly into QGIS (and back into R).
writeRaster(rCE, "/path/filename.tif")
should be sufficient.
That said, there is a way to assign a projection to a .asc file, and that is to create a .prj file, much like you'd have with a shapefile.
Create a set of point from your raster, then check the CRS, then save as a shapefile:
> pts = as(r,"SpatialPoints")
> crs(pts)
CRS arguments: +proj=longlat +datum=WGS84 +no_defs
> shapefile(pts, "pts.shp")
Now copy the file pts.shp
into the same folder as your raster, give it the same name as your raster but with a .prj
extension.
Now QGIS (and other GDAL tools) will interpret that file as the projection of the .asc
file.
This is not ideal, because now you have two files to keep together. And .asc files are grim, because you can't store multiple bands or have rasters with non square (eq 12m x 24m) cells. But that knowledge might get you out of a spot if you need it.