[R-sig-Geo] spliting lines on equal-space points.
Roger.Bivand at nhh.no
Fri Oct 3 09:12:11 CEST 2008
On Thu, 2 Oct 2008, milton ruser wrote:
> Dear all,
> I have a shapefile with line features (like for example drainage),
> and I need to generate another shape with points using
> the features from the first shape.
> But the points is not the points that I can get from the lines.
> I need, for example, define that I want one point each 50 meters,
> and the points have ~ 50 meters of space between other points
> if we follow the "flow" of drainage.
> I wrote this simple code to try short the time for helpers.
> xx <- readShapeLines(system.file("shapes/fylk-val.shp",
> proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))
> plot(xx, col="blue", axes=T)
> plot(xx.selectone, col="red", add=T)
spsample(xx.selectone, n=82, type="regular")
gets you there directly - choose n either directly (here roughly one
sample per km) or based on the object length:
sum(sapply(slot(xx.selectone, "lines"), function(x) sapply(slot(x,
Also see the spsurvey package for an industry-strength development of
sampling in stream networks.
> Best wishes,
> miltinho astronauta
> [[alternative HTML version deleted]]
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo