[R-sig-Geo] inconsistent as.data.frame(SpatialPointsDF)

dschneiderch Dominik.Schneider at colorado.edu
Fri Mar 20 17:35:43 CET 2015


Hi -
Thanks for your replies.
I should have mentioned, I made sure to test this with a clean workspace
before posting and confirmed the behavior this morning. it sounds like the
names of the coordinates should never change?
another example of the names being converted at the prompt from Longitude,
Latitude to x,y.
> library('ProjectTemplate')
> load.project() #since i'm loading the data from a cached .rdata file, it
> is always the same to begin. please excuse the slightly different variable
> names. locs = snotellocs[1:10,]
... bunch of packages loading ... and cached data loading ...
> head(str(snotellocs))
Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
  ..@ data       :'data.frame':	315 obs. of  7 variables:
  .. ..$ network     : chr [1:315] "SNTL" "SNTL" "SNTL" "SNTL" ...
  .. ..$ State       : chr [1:315] "AZ" "AZ" "AZ" "AZ" ...
  .. ..$ Station_ID  : chr [1:315] "11R06S" "11R07S" "09S01S" "09S06S" ...
  .. ..$ Site_ID     : int [1:315] 308 1140 310 902 1143 1139 416 1121 488
511 ...
  .. ..$ Site_Name   : chr [1:315] "BAKER BUTTE" "BAKER BUTTE SMT" "BALDY"
"BEAVER HEAD" ...
  .. ..$ Elevation_ft: int [1:315] 7300 7700 9125 7990 9200 7100 8400 7350
7200 9020 ...
  .. ..$ Elevation_m : int [1:315] 2225 2347 2781 2435 2804 2164 2560 2240
2195 2749 ...
  ..@ coords.nrs : int [1:2] 7 6
  ..@ coords     : num [1:315, 1:2] -111 -111 -110 -109 -109 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : NULL
  .. .. ..$ : chr [1:2] "Longitude" "Latitude"
  ..@ bbox       : num [1:2, 1:2] -112.2 33 -105.1 43.7
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:2] "Longitude" "Latitude"
  .. .. ..$ : chr [1:2] "min" "max"
  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
  .. .. ..@ projargs: chr "+proj=longlat +datum=WGS84 +ellps=WGS84
+towgs84=0,0,0"
NULL
> head(as.data.frame(snotellocs))
          x        y network State Station_ID Site_ID       Site_Name
1 -111.4064 34.45660    SNTL    AZ     11R06S     308     BAKER BUTTE
2 -111.3827 34.45547    SNTL    AZ     11R07S    1140 BAKER BUTTE SMT
3 -109.5034 33.97883    SNTL    AZ     09S01S     310           BALDY
4 -109.2166 33.69144    SNTL    AZ     09S06S     902     BEAVER HEAD
5 -109.0571 36.32678    SNTL    AZ     09N05S    1143   BEAVER SPRING
6 -112.0623 35.26247    SNTL    AZ     12P01S    1139       CHALENDER
  Elevation_ft Elevation_m
1         7300        2225
2         7700        2347
3         9125        2781
4         7990        2435
5         9200        2804
6         7100        2164


> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
[1] C

attached base packages:
[1] grid      parallel  stats     graphics  grDevices utils     datasets
[8] methods   base

other attached packages:
 [1] ncdf4_1.13          smwrBase_1.0.1      lubridate_1.3.3
 [4] digest_0.6.8        memoise_0.2.1       gridExtra_0.9.1
 [7] spdep_0.5-82        Matrix_1.1-4        fields_7.1
[10] maps_2.3-9          spam_1.0-1          doSNOW_1.0.12
[13] snow_0.3-13         doMC_1.3.3          iterators_1.0.7
[16] foreach_1.4.2       ipred_0.9-3         MASS_7.3-37
[19] RColorBrewer_1.1-2  rgdal_0.9-1         stringr_0.6.2
[22] ggplot2_1.0.0       plyr_1.8.1          reshape2_1.4.1
[25] raster_2.3-12       sp_1.0-17           ProjectTemplate_0.6

loaded via a namespace (and not attached):
 [1] LearnBayes_2.15  Rcpp_0.11.3      boot_1.3-13      class_7.3-11
 [5] coda_0.16-1      codetools_0.2-9  colorspace_1.2-4 deldir_0.1-7
 [9] gtable_0.1.2     lattice_0.20-29  lava_1.3         munsell_0.4.2
[13] nlme_3.1-118     nnet_7.3-8       prodlim_1.5.1    proto_0.3-10
[17] rpart_4.1-8      scales_0.2.4     splines_3.1.2    survival_2.37-7




--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/inconsistent-as-data-frame-SpatialPointsDF-tp7587920p7587928.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list