Create Nodes at lines' segments extremities.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Create Nodes at lines' segments extremities.

Tristan Bourgeois
Hi everybody,

I can't find any infomation about the gis manipulation I want to process on
R. Even if there are similar posts on r-sig-geo archives...


My issue is the following one :

>*myline<-readOGR(dsn = "./shapes/shp_tr_topo",layer =
"TRONCON_TOPO_Bresle" ) is a spatial polyline which is composed of :*

> *length(line@lines)*
[1] 585                   => 585 segments


It seems that each of those 585 lines are acually a serie of points :

*> line@lines[[1]]@Lines*
[[1]]
An object of class "Line"
Slot "coords":
          [,1]    [,2]
 [1,] 609046.7 6956543
 [2,] 609057.3 6956543
 [3,] 609077.6 6956546
 [4,] 609103.2 6956553
 [5,] 609132.5 6956561
 [6,] 609146.0 6956568
 [7,] 609157.4 6956574
 [8,] 609167.0 6956577
 [9,] 609176.9 6956581
[10,] 609184.4 6956585
[11,] 609191.9 6956588
[12,] 609199.3 6956591
[13,] 609205.7 6956594
[14,] 609212.6 6956599
[15,] 609216.6 6956604
[16,] 609222.6 6956609
[17,] 609229.0 6956613
[18,] 609237.9 6956619
[19,] 609244.4 6956623
[20,] 609253.5 6956626
[21,] 609265.2 6956631
[22,] 609276.5 6956636
[23,] 609287.4 6956639
[24,] 609296.9 6956644
[25,] 609305.1 6956647
[26,] 609308.6 6956653

What I want to obtain are the coordinates of each segments extremities. So
for a segment I should have 2 points with X,Y values.
I tried to apply the rgeos Gnode function but nothing appears as changed.
Maybe there's something to do with the min and max X,Y of each segments ?


Does somebody has already done /wrote a similar script to process that ??


Thank you in advance for the helpfull advices.

Cheers.

Tristan Bourgeois
Hydromorphologist Engineer
Seine Normandie Water Agency
Rouen, France

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create Nodes at lines' segments extremities.

edzer

(after receiving the data, off-list):

library(sp)
library(rgdal)
x = readOGR("TRONCON_TOPO_Bresle.shp")

lapply(x@lines, function(y) lapply(y@Lines, function(z) apply(z@coords,
2, range)))

gives you the bounding box of each individual Line element, as a nested
list (similar to how x@lines is nested).



On 02/03/17 17:53, Tristan Bourgeois wrote:

> Hi everybody,
>
> I can't find any infomation about the gis manipulation I want to process on
> R. Even if there are similar posts on r-sig-geo archives...
>
>
> My issue is the following one :
>
>> *myline<-readOGR(dsn = "./shapes/shp_tr_topo",layer =
> "TRONCON_TOPO_Bresle" ) is a spatial polyline which is composed of :*
>
>> *length(line@lines)*
> [1] 585                   => 585 segments
>
>
> It seems that each of those 585 lines are acually a serie of points :
>
> *> line@lines[[1]]@Lines*
> [[1]]
> An object of class "Line"
> Slot "coords":
>           [,1]    [,2]
>  [1,] 609046.7 6956543
>  [2,] 609057.3 6956543
>  [3,] 609077.6 6956546
>  [4,] 609103.2 6956553
>  [5,] 609132.5 6956561
>  [6,] 609146.0 6956568
>  [7,] 609157.4 6956574
>  [8,] 609167.0 6956577
>  [9,] 609176.9 6956581
> [10,] 609184.4 6956585
> [11,] 609191.9 6956588
> [12,] 609199.3 6956591
> [13,] 609205.7 6956594
> [14,] 609212.6 6956599
> [15,] 609216.6 6956604
> [16,] 609222.6 6956609
> [17,] 609229.0 6956613
> [18,] 609237.9 6956619
> [19,] 609244.4 6956623
> [20,] 609253.5 6956626
> [21,] 609265.2 6956631
> [22,] 609276.5 6956636
> [23,] 609287.4 6956639
> [24,] 609296.9 6956644
> [25,] 609305.1 6956647
> [26,] 609308.6 6956653
>
> What I want to obtain are the coordinates of each segments extremities. So
> for a segment I should have 2 points with X,Y values.
> I tried to apply the rgeos Gnode function but nothing appears as changed.
> Maybe there's something to do with the min and max X,Y of each segments ?
>
>
> Does somebody has already done /wrote a similar script to process that ??
>
>
> Thank you in advance for the helpfull advices.
>
> Cheers.
>
> Tristan Bourgeois
> Hydromorphologist Engineer
> Seine Normandie Water Agency
> Rouen, France
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> 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; +49 251 83 33081
Journal of Statistical Software:   http://www.jstatsoft.org/
Computers & Geosciences:   http://elsevier.com/locate/cageo/


_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

signature.asc (484 bytes) Download Attachment
Loading...