[R-sig-Geo] writeRaster do not take the coordinate reference from the raster

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Sat Feb 1 13:14:25 CET 2014


Some raster file types don't let you store the coordinate reference
system. Arc/Info Ascii Grid files are just the grid size and shape in
a header and the values, with no provision for a CRS field. (Unless
esri updated the file spec since I last used them...)

Saving as a GeoTIFF should preserve it in the file's metadata.

Barry


On Fri, Jan 31, 2014 at 10:13 PM, Manuel Spínola <mspinola10 at gmail.com> wrote:
> Dear list members,
>
> When using the function writeRaster (raster package) the coord. ref shows
> NA, even when the raster has a coord. ref.
>
> How can I keep the coord. ref. in my output raster?
>
>> show(distAc_gam)
> class       : RasterLayer
> dimensions  : 477, 746, 355842  (nrow, ncol, ncell)
> resolution  : 100, 100  (x, y)
> extent      : 450664.7, 525264.7, 1076344, 1124044  (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=tmerc +lon_0=-84 +lat_0=0 +x_0=500000 +k=0.9999
> +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
> data source : in memory
> names       : layer
> values      : 0, 12081.39  (min, max)
>
>
>> writeRaster(distAc_gam, filename = "Raster_distAc.asc", overwrite = TRUE)
> class       : RasterLayer
> dimensions  : 477, 746, 355842  (nrow, ncol, ncell)
> resolution  : 100, 100  (x, y)
> extent      : 450664.7, 525264.7, 1076344, 1124044  (xmin, xmax, ymin, ymax)
> coord. ref. : NA
> data source :
> /Users/manuelspinola/Dropbox/Proyectos_en_R/Viviana_Narvaez/Raster_distAc.asc
> names       : Raster_distAc
>
>
>
>
>
> --
> *Manuel Spínola, Ph.D.*
> Instituto Internacional en Conservación y Manejo de Vida Silvestre
> Universidad Nacional
> Apartado 1350-3000
> Heredia
> COSTA RICA
> mspinola at una.ac.cr
> mspinola10 at gmail.com
> Teléfono: (506) 2277-3598
> Fax: (506) 2237-7036
> Personal website: Lobito de río <https://sites.google.com/site/lobitoderio/>
> Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>
>
>         [[alternative HTML version deleted]]
>



More information about the R-sig-Geo mailing list