Hi Erin ! Yes, I tried to apply my function to "UH" which is a shapefile.
2017-01-27 11:28 GMT+01:00 Hodgess, Erin <hodge...@uhd.edu>: > Hi Tristan! > > I'm looking at your code right now. What is your input, please; the UH? > > Thanks, > Erin > > > Erin M. Hodgess > Associate Professor > Department of Mathematics and Statistics > University of Houston - Downtown > mailto: hodge...@uhd.edu > > ________________________________________ > From: R-sig-Geo <r-sig-geo-boun...@r-project.org> on behalf of Tristan > Bourgeois <tristan.bourge...@gmail.com> > Sent: Friday, January 27, 2017 3:41 AM > To: r-sig-geo@r-project.org > Subject: [R-sig-Geo] R function checking/transforming CRS layer R function > > Dear all, > > I'm trying to build up an r function able to check if the projection system > of a layer is in Lambert93 (WSG code : 2154) . > If the condition is false I want to transform the CRS into Lambert 93. > > This is what I wrote : > > > CRSfunction<-function(couche) > + { > + prj_couche<-CRS(couche) > + prj<-CRS("+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 > +x_0=700000 +y_0=6600000 +ellps=GRS80 +units=m +no_defs") > + if (prj_couche!=prj) > + {CRS(couche)="+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 > +x_0=700000 +y_0=6600000 +ellps=GRS80 +units=m +no_defs" } > + } > > CRSfunction(UH) > Error in CRS(couche) : no method for coercing this S4 class to a vector > In addition: Warning message: > In is.na(projargs) : is.na() applied to non-(list or vector) of type 'S4' > Called from: CRS(couche) > Browse[1]> Q > > > Does anybody can help to deal with the mistake I 've made ?? > > Plus, I'm not sure the function will work with both raster and shapefiles. > > Cheers. > > > Tristan Bourgeois. > R New User > > [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > -- Tristan Bourgeois [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo