[R-sig-Geo] converting line segment into polyline

Rolf Turner r.turner at auckland.ac.nz
Mon Dec 19 08:30:58 CET 2011


As it stands, your question does not make a lot of sense.  A psp object
is a collection of (in general) unrelated line segments. A *polyline*
in my understanding is a collection of *related* line segments ``joined
end to end''.  I.e. a polyline is effectively a sequence of points (x_i,y_i)
where (conceptually at least) the i-th point is joined to the (i+1)-st
point by a line segment.

Hence, in a sense, there is an enormous number of ways in which
a psp object could be turned into a polyline --- arrange the segments
in arbitrary order and then "join" the second point of the i-th segment
to the first point of the (i+1)-st segment.  (The first point of each 
segment
is ``already joined'' to the second point of that segment.)

Few if any of these ``ways'' would be meaningful or useful.

You will have to be much more clear and explicit in your question if
you want any real help.

BTW what do you mean by ``***back*** into a polyline''?
Please note the dictum:  "R lacks a mind_read() function."
As do I.

     cheers,

         Rolf Turner

P. S.  I do not know if there is formal "polyline" class (either S3 or S4)
defined in any R package.  If there is, please enlighten me.

The PBSmapping package has a class "PolySet"; a PolySet object is in
effect a collection of polylines.

         R. T.

On 19/12/11 10:40, Miaoying Shi wrote:
> Hello, Lists,
>
>   I have been searching a method to convert psp format line segment back
> into polyline, as the psp data (p1) is like below, is there anyone can help
> me?  Thanks a lot!
>
> Erin
>
>
>
>> str(p1)
> List of 5
>   $ ends      :'data.frame':     22511 obs. of  4 variables:
>    ..$ x0: num [1:22511] 233994 233966 233949 233929 233885 ...
>    ..$ y0: num [1:22511] 3355530 3355519 3355515 3355508 3355533 ...
>    ..$ x1: num [1:22511] 233946 233918 233911 233873 233889 ...
>    ..$ y1: num [1:22511] 3355510 3355511 3355512 3355513 3355514 ...
>   $ window    :List of 4
>    ..$ type  : chr "rectangle"
>    ..$ xrange: Named num [1:2] 228691 236822
>    .. ..- attr(*, "names")= chr [1:2] "min" "max"
>    ..$ yrange: Named num [1:2] 3347926 3356435
>    .. ..- attr(*, "names")= chr [1:2] "min" "max"
>    ..$ units :List of 3
>    .. ..$ singular  : chr "unit"
>    .. ..$ plural    : chr "units"
>    .. ..$ multiplier: num 1
>    .. ..- attr(*, "class")= chr "units"
>    ..- attr(*, "class")= chr "owin"
>   $ n         : int 22511
>   $ marks     : int [1:22511] 37 37 37 37 37 37 37 37 100 100 ...
>   $ markformat: chr "vector"
>   - attr(*, "class")= chr [1:2] "psp" "list"
>
> 	[[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



More information about the R-sig-Geo mailing list