-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Seth, after running your script, I tried:
b = gBuffer(t.sl, width = .1, byid=FALSE) plot(b, col='#ff000088', add=TRUE) i = gIntersection(b, v.sldf, byid = TRUE) plot(i, col = 'blue', add=TRUE) pts = spsample(i[1], n=1, type='random') l = lapply(1:length(i), function(x) spsample(i[x], n=1, type='random')) npts = do.call(rbind, l[!sapply(l, is.null)]) plot(npts, add=TRUE, col = 'green') which goes a fixed distance from the transect, but not a fixed distance along each contour. Note that you get one point per unique contour level. On 10/09/2013 03:01 PM, Seth Bigelow wrote: > Barry, > > I do mean exactly what you have stated, i.e., "plus or minus up to > 50m either side of the points created by your plot, but along the > contour line? In other words, I go to each of those points on your > plot, choose a runif(1,-50,50) and traverse that distance on the > contour line to get my sampling point?" > > In my real-world application, there do not seem to be either of the > 'edge' issues you raise, since the flank of the mountain I am > sampling is not highly dissected. But if the contour line is a > loop, it would be fine to 'go around', or just throw an 'NA'. > Similarly, if the contour line ends, an 'NA' would be ok. > > Thanks for thinking about this! > > -Seth Bigelow > > > -----Original Message----- From: [email protected] > [mailto:[email protected]] On Behalf Of Barry Rowlingson Sent: > Wednesday, October 09, 2013 8:18 AM To: Seth Bigelow Cc: > [email protected] Subject: Re: [R-sig-Geo] random sampling > along contour > > On Wed, Oct 9, 2013 at 12:32 PM, Seth Bigelow <[email protected]> > wrote: >> Hello all: >> >> >> >> I wish to place sampling plots at regular elevation intervals up >> a > mountain. >> Plot centers should be placed at random within a 100 m wide >> transect along the contour. Can anyone suggest an efficient way >> of doing this? Code below places plots on a single transect on >> the volcano dataset, but does not do the 'along the contour' >> randomization. > > I'm not clear what you mean here, the plot is a big help though > and +1 for that. > > By "a 100m wide transect along the contour" do you mean plus or > minus up to 50m either side of the points created by your plot, but > along the contour line? In other words, I go to each of those > points on your plot, choose a runif(1,-50,50) and traverse that > distance on the contour line to get my sampling point? > > What if the contour line at that point is a loop less than 100m > long? Do I go around? The other edge case is literally an edge case > - when the contour line hits the edge... > > Barry > > _______________________________________________ R-sig-Geo mailing > list [email protected] > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > - -- Edzer Pebesma Institute for Geoinformatics (ifgi), University of Münster Heisenbergstraße 2, 48149 Münster, Germany. Phone: +49 251 83 33081 http://ifgi.uni-muenster.de GPG key ID 0xAD3A77F1 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSVWfqAAoJEM1OCHCtOnfxDnsIAIapaJ3hiSN5D1Y7e4uUEYeH rg8vvTCCzQjQxc1472wyUZYfK552kUugA+C0IYP97HWAEzMQkkPVI1EFCm2f3Cpo 6OBkSMvfaU+TM/Q7WMnDJqry0AKXXc576fgpAnYXktavgzzuEDbaFg5yAg717ZYz SBrThQ8b0148DtWEHGsXQbBJvfxQY6ymhlPWBNQD2hKsqN+A/j27RADCdehmDnNk ZkMUGN2ehxKrX9MrkdNU0JFLr41diKzNeqsULzr4YH2yyzTiQqKsPdF7PvmuEdqK 2tGNpOi2SWimLWcXpdXQ2NqGVhKkPzC5Pj0K4fXBs4n4QES2Q6cc2XgKJOeCaKU= =qGv9 -----END PGP SIGNATURE----- _______________________________________________ R-sig-Geo mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
