Skip to content
Prev 274368 / 398506 Next

getting data associated with coordinates in a spatial data frame

Michael,
Thank you for the tips. The suggestion didn't work though. Here is the output of str(e):
Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
  ..@ data       :'data.frame': 168 obs. of  2 variables:
  .. ..$ catchcandata: num [1:168] 47.2 50.4 53.7 58 69.8 ...
  .. ..$ section     : Factor w/ 1 level "16 Sept F9": 1 NA NA NA NA NA NA NA NA NA ...
  ..@ coords.nrs : int [1:2] 1 2
  ..@ coords     : num [1:168, 1:2] 0 0 0 0 0 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : NULL
  .. .. ..$ : chr [1:2] "x" "y"
  ..@ bbox       : num [1:2, 1:2] 0 0 48.8 17.1
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:2] "x" "y"
  .. .. ..$ : chr [1:2] "min" "max"
  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
  .. .. ..@ projargs: chr NA 

-----Original Message-----
From: R. Michael Weylandt [mailto:michael.weylandt at gmail.com] 
Sent: Thursday, October 13, 2011 11:13 AM
To: Bailey, Daniel
Cc: Sarah Goslee; r-help at r-project.org
Subject: Re: [R] getting data associated with coordinates in a spatial data frame

It's going to depend how the coordinates are stored within the data frame. Do you perhaps know if they are factors or character strings?
(I'm not familiar with the package). If you don't know, type
str(NAMEOFYOUROBJECT) and we can help interpret the output.

Untested, I think this would actually work for both though:
e[as.character(e$coordinates)=="(0,17)",]

Michael
On Thu, Oct 13, 2011 at 2:05 PM, Bailey, Daniel <bailed at spu.edu> wrote: