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

MacQueen, Don m@cqueen1 @ending from llnl@gov
Thu Sep 20 17:05:42 CEST 2018


First, it looks like prcp_sites_ll does not have CRS information, because @projargs is NA. You'll need something like

  proj4string(prcp_sites_ll) <- CRS('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0')

That string may have more than is necessary; you could also try

   CRS('+init=epsg:4326')

Otherwise, your spTransform() command looks ok to me.

(have you come across spatialreference.org? I find it useful. Example
   http://spatialreference.org/ref/epsg/wgs-84/
)

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 9/20/18, 7:29 AM, "R-sig-Geo on behalf of Rich Shepard" <r-sig-geo-bounces using r-project.org on behalf of rshepard using appl-ecosys.com> wrote:

       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
    
    _______________________________________________
    R-sig-Geo mailing list
    R-sig-Geo using r-project.org
    https://stat.ethz.ch/mailman/listinfo/r-sig-geo
    



More information about the R-sig-Geo mailing list