[R-sig-Geo] Import custom projection in R

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Aug 29 13:21:18 CEST 2013


On Thu, Aug 29, 2013 at 11:46 AM, Pan <pan.sapiens.it at gmail.com> wrote:
> Dear Roger,
>
> Thank you for your valuable suggestions. First, I tried to enter my.proj as PROJ.4 string:
>
>   > MyProj.PROJ.4<-"+proj=UTM +datum=WGS84 +lon_0=17 +x_0=600000 +y_0=10000000"
>   >
>   > library(rgdal)
>   >
>   > CRS("+proj=UTM +lon_0=17 +x_0=600000 +y_0=10000000")
> Error in CRS("+proj=UTM +lon_0=17 +x_0=600000 +y_0=10000000") :
>     unknown projection id
>   >
>   > CRS(paste("+proj=UTM +lon_0=17 +x_0=600000 +y_0=10000000"))
> Error in CRS(paste("+proj=UTM +lon_0=17 +x_0=600000 +y_0=10000000")) :
>     unknown projection id

proj4 strings are case-sensitive:

 > p="+proj=UTM +datum=WGS84 +lon_0=17 +x_0=600000 +y_0=10000000"
 > CRS(p)
 Error in CRS(p) : unknown projection id
 > p="+proj=utm +datum=WGS84 +lon_0=17 +x_0=600000 +y_0=10000000"
 > CRS(p)
 CRS arguments:
  +proj=utm +datum=WGS84 +lon_0=17 +x_0=600000 +y_0=10000000 +ellps=WGS84
 +towgs84=0,0,0


> I tried to read a projected shapefile and retrieve the string from it because I'm not particularly familiar with PROJ.4 and I was not sure
> whether the string was correct.

 Just open the .prj file in a text editor (such as notepad on Windows)
- it is plain text.

Barry



More information about the R-sig-Geo mailing list