[R-sig-Geo] create projection for a .asc file in Rstudio

basile.lenormand b@@||e@|enorm@nd @end|ng |rom protonm@||@com
Mon Dec 6 17:53:52 CET 2021


Good evening every ones.

I am trying to set a projection system for an ascii file in Rstudio.

I reached to import the .asc on R and to plot it. Now I need to set a projection.

In my matrix I have CRS : NA

I tried two ways :

First way:

crs(rasterClimat, asText=F)
crs(rasterClimat)<- "+proj=lcc +lat_1=48 +lat_2=33 +lon_0=-100 +datum=WSG84"

crs(rasterClimat)

w<- wkt(rasterClimat)

w

cat(w, "\n")

(taken from here :https://rdrr.io/cran/raster/man/projection.html)

Second way:

crs(rasterClimat)<-"proj=longlat +datum=WGS84 +no_defs +ellps=WGS84+towgs84= 0,0,0"

(taken from here : https://www.youtube.com/watch?v=iqbVyt8mjIk, tutorial that I followed)

For the two methods, the error message is the same :

Error in sp::CRS(SRS_string = x) : NA

I followed the youtube tutorial, our two cases seem similar but she reached to project her map.

May someone gives me some clues about what I do not understand in this process and where I have to look for and/or what can I do to fix it?
I want to do it on R, I do not want to use a GISsoftware to set the coordinate system then import the file into R.

I put in attachment the code I used if you want to have a close look, and the .asc files.

Thank you very much for your time,
best regards,

Basile.

Sent with [ProtonMail](https://protonmail.com/) Secure Email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20211206/28043421/attachment.html>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ascii to raster.R
Type: application/octet-stream
Size: 736 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20211206/28043421/attachment.obj>


More information about the R-sig-Geo mailing list