[R] calculating distance inland from coastline

2011-07-14 Thread Simon Goodman
Hi All, Does anybody know of any existing functions that will calculate distance inland from a coastline? It's possible to test if a lon,lat location is land or sea using map.where(), but I need to add a buffer to this of say 2km, to allow for points that are just on the coast, and below the

Re: [R] Testing if a variable is specified within a function adding TRUE/FALSE options to functions

2011-06-30 Thread Simon Goodman
Many thanks, I think that should help. I'll give it a go. -- View this message in context: http://r.789695.n4.nabble.com/Testing-if-a-variable-is-specified-within-a-function-adding-TRUE-FALSE-options-to-functions-tp3633248p3635979.html Sent from the R help mailing list archive at Nabble.com.

[R] Testing if a variable is specified within a function adding TRUE/FALSE options to functions

2011-06-29 Thread Simon Goodman
I have 2 related questions about functions. 1. I am writing a function to plot data from a time series with the form myplot-function(data, d1,d2) {} Where d1 and d2 are two dates in a time series. The idea being that if no values for d1 and d2 are entered then the function defaults to

[R] setting 'layout' locally within functions

2011-06-22 Thread Simon Goodman
Using layout I've created a function that makes a 2 panel plot - comprising a main plot, and a sub-panel with custom legend. I would now like to use layout to create multiple panels with plots created by my function, however the values for layout set in the function act globally, stopping me from

Re: [R] Extract time only from POSIXlt object

2011-01-30 Thread Simon Goodman
Those are all really helpful responses. Got it sorted now. Many thanks indeed! -- View this message in context: http://r.789695.n4.nabble.com/Extract-time-only-from-POSIXlt-object-tp3246751p3247105.html Sent from the R help mailing list archive at Nabble.com.

[R] Extract time only from POSIXlt object

2011-01-29 Thread Simon Goodman
How can I extract only the time component from an POSIXlt object? For example if I try the following it still returns both the date and time... as.POSIXlt(tr.date[1]) [1] 2010-10-18 21:46:53 as.POSIXlt(tr.date[1],%H:%M:%S) [1] 2010-10-18 21:46:53 round and trunc don't help... is there an

Re: [R] overlaying a levelplot on a map plot

2010-04-23 Thread Simon Goodman
Thanks so much for that elegant solution... it works extremely well. I'm now trying to add lines, points and polygons to show transects, locations of the original data points and the bounding polygon of the study area. Presumably I can use panel.polygonsplot, panel.pointsplot for this? --

Re: [R] overlaying a levelplot on a map plot

2010-04-22 Thread Simon Goodman
Thanks for the suggestions Unfortunately contour won't in this case as it expects the x,y values to be in an ascending sequence. -- View this message in context: http://r.789695.n4.nabble.com/overlaying-a-levelplot-on-a-map-plot-tp2019419p2020292.html Sent from the R help mailing list

Re: [R] overlaying a levelplot on a map plot

2010-04-22 Thread Simon Goodman
Thanks for those pointers making some progress now The following will put the levelplot on to the map, but the not with the co-ordinates aligned... The level plot appears on a slightly larger scale compared to the underlying map. In both the map and levelplot, the coordinates are in lon,

[R] overlaying a levelplot on a map plot

2010-04-21 Thread Simon Goodman
I've generated a levelplot showing the density distribution of a species derived from survey transects, with lon, lat co-ordinates. I'd like to overlay this on a map of the study region specified by: map('worldHires', xlim = range(mlon), ylim = range(mlat)), where mlon, mlat specifies the study

[R] generating a SpatialLinesDataFrame (rgdal)

2010-04-16 Thread Simon Goodman
Could somebody give me a pointer on how to generate a SpatialLinesDataFrame from a dataframe, that contains lat,long coordinates as separate variables. At the moment the data looks like this: lat long [1] 53. 1. where as the SpatialLinesDataFrame consists of