[R-sig-Geo] uniformly sample points on a border of a polygon

Paolo Piras paolo.piras at uniroma3.it
Sun Oct 16 15:53:15 CEST 2016


Thanks Jeff,

this solution also works quite well!

Thanks again to all those that proposed different solutions.

Best

Paolo


________________________________
Da: R-sig-Geo <r-sig-geo-bounces at r-project.org> per conto di Hollister, Jeff <Hollister.Jeff at epa.gov>
Inviato: domenica 16 ottobre 2016 15.30
A: r-sig-geo at r-project.org
Oggetto: Re: [R-sig-Geo] uniformly sample points on a border of a polygon

And for another option, using sp::spsample


mypol<-round(matrix(c(-13.8447497369687, -3.51439434200449,
                              6.09494902836977, 6.83498916728338,
                              9.20403746769121, 15.3061452155498,
                              18.4050681631565, 15.334153355932,
                              9.21809033073377, 6.90467983448734,
                              6.17942233200763, -3.4864867866601,
                              -13.8299219386242, -17.5237987124776,
                              -17.2262670680261, -17.5217563171495,
                              -2.29667185082115, -7.72275721405543,
                              -9.77084968112857, -8.81725304021858,
                              -8.32894043391822, -4.76080777897439,
                              -0.0600572363382094, 4.62779963258511,
                              8.20771806467615, 8.70484104396818,
                              9.68531129857718, 7.67574865642846,
                              2.46081860449754, 1.31152149442131,
                              0.0845735294613392, -1.11988475144136),
                            ncol=2),digits=2)
mypol <- SpatialPolygons(list(Polygons(list(Polygon(mypol)),ID = "1")))
pts <- spsample(as(mypol, "SpatialLines"), 100, "regular")
plot(mypol)
plot(pts, add=T,col="red")

Cheers,

Jeff


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
R-sig-Geo Info Page<https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
stat.ethz.ch
R-sig-Geo -- R Special Interest Group on using Geographical data and Mapping About R-sig-Geo




	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list