Skip to content
Back to formatted view

Raw Message

Message-ID: <CANVKczMndiSkjDK19M5u0sk2S-LLBZhV8V8bGOQ=+vd=+pHjwg@mail.gmail.com>
Date: 2014-02-01T12:14:25Z
From: Barry Rowlingson
Subject: writeRaster do not take the coordinate reference from the raster
In-Reply-To: <4f38846cd24b47cd80e5f4c7a1545d83@EX-0-HT0.lancs.local>

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]]
>