[R-sig-Geo] Using CRS() method on SpatialPointDataFrame to project coordinates

Rich Shepard r@hep@rd @ending from @ppl-eco@y@@com
Thu Sep 20 16:29:29 CEST 2018


   I have a SpatialPointsDataFrame with geographic coordinates:

#> str(prcp_sites_ll)
Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
   ..@ data       :'data.frame':	58 obs. of  3 variables:
   .. ..$ name     : Factor w/ 58 levels "Blazed Alder",..: 1 2 3 4 5 6 7 8 9 10 ...
   .. ..$ elev     : num [1:58] 1112.5 159.1 162.2 45.4 57.3 ...
   .. ..$ mean_prcp: num [1:58] 0.362 0.155 0.16 0.12 0.128 ...
   ..@ coords.nrs : int [1:2] 2 3
   ..@ coords     : num [1:58, 1:2] -122 -122 -122 -123 -123 ...
   .. ..- attr(*, "dimnames")=List of 2
   .. .. ..$ : NULL
   .. .. ..$ : chr [1:2] "easting" "northing"
   ..@ bbox       : num [1:2, 1:2] -122.8 45 -121.7 45.5
   .. ..- attr(*, "dimnames")=List of 2
   .. .. ..$ : chr [1:2] "easting" "northing"
   .. .. ..$ : chr [1:2] "min" "max"
   ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
   .. .. ..@ projargs: chr NA

and I want to project this using CRS('+init=epsg:2838') to a new SPDF
called prcp_sites_lcc.

   I think the proper syntax would be:

prcp_sites_lcc <- spTransform(prcp_sites_ll,CRS('+init=epsg:2838'))

   Is this correct?

Regards,

Rich



More information about the R-sig-Geo mailing list