[R-sig-Geo] Defining CRS when loading a raster doesn't seems to work anymore

Robert J. Hijmans r.hijmans at gmail.com
Sun Nov 17 20:51:46 CET 2013


I think it was possible; the 'crs' argument is passed on by the
ellipsis; but only if the file had an unknown crs (it is in the help
file under Details).

I think it broke because of a change in sp (or rgdal). Previously, if
the crs was unknown, the CRS object would store "NA" (with quotes),
now it has NA (no quotes). That seems to be an improvement but broke
the raster code. This has been fixed for the next version of raster.

Robert

On Sun, Nov 17, 2013 at 8:27 AM, Michael Sumner <mdsumner at gmail.com> wrote:
> I don't think it ever was possible to do this. If you look carefully
> at the Details for ?raster, it mentions extra arguments passed via ...
> and none of these is "crs" for the "character" method. That can be a
> bit obscure until you understand that the character method (for a
> file) does not allow you to pass in crs at that point, it's only
> defined for the signatures  "missing", "Extent", "matrix" and
> "big.matrix".
>
> Does that make sense?
>
> On Fri, Nov 15, 2013 at 6:35 PM, Arnaud Mosnier <a.mosnier at gmail.com> wrote:
>> Hi Jan,
>>
>> Thanks.
>> You can also use
>> proj4string(r) <- "+proj=longlat +ellps=WGS84"
>>
>> but the problem (the bug ?) is that it does not work anymore defining
>> directly the crs into the raster function.
>>
>> Arnaud
>>
>>
>> 2013/11/15 Verbesselt, Jan <jan.verbesselt at wur.nl>
>>
>>> Hi Arnaud,
>>>
>>> Something like:
>>>
>>> r <- raster()
>>> projection(r)
>>> projection(r) <- "+proj=lcc +lat_1=48 +lat_2=33 +lon_0=-100 +ellps=WGS84"
>>> projection()
>>>
>>>
>>> Might help,
>>>
>>> Best,
>>> Jan
>>>
>>>
>>> On 15/11/13 17:52, "Arnaud Mosnier" <a.mosnier at gmail.com> wrote:
>>>
>>> >Hi all,
>>> >
>>> >I re-run a script written some times ago containing a line like the
>>> >following
>>> >
>>> >test <- raster("myraster.tif", crs = "+proj=longlat +ellps=WGS84")
>>> >
>>> >The file is loaded correctly, but the crs was not attributed.
>>> >
>>> >>proj4string(test)
>>> >
>>> >gives me
>>> >
>>> >[1] "NA"
>>> >
>>> >
>>> >When looking at the help file, nothing seems to have changed, so what the
>>> >problem ?
>>> >Any suggestion ?
>>> >
>>> >Thanks
>>> >
>>> >Arnaud
>>> >
>>> >       [[alternative HTML version deleted]]
>>> >
>>> >_______________________________________________
>>> >R-sig-Geo mailing list
>>> >R-sig-Geo at r-project.org
>>> >https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>> >
>>>
>>>
>>>
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>
> --
> Michael Sumner
> Hobart, Australia
> e-mail: mdsumner at gmail.com
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list