[R-sig-Geo] split SLDF with attributes

Bacou, Melanie mel at mbacou.com
Fri Feb 24 07:45:47 CET 2017


Marta,
Option 1) using CreateSegments() seems to do what you want. Why don't 
you simply use rgeos::over() or rgeos::gTouches() between your old and 
new SLDFs to match the index positions of your old attributes to your 
new segments?

--Mel.


On 2/23/2017 2:27 PM, marta azores wrote:
> Hi all,
>
> I am working with a large datasets of boat positions, and based on this
> points I created a SpatialLinesDataFrame. Now, I would like to
> split/divide SpatialLinesDataframe
> into n segments of 10km and keep the attributes. So far, I have tried
> multiple things:
>
> 1.      The function from this website: http://rstudio-pubs-static.s3.
> amazonaws.com/10685_1f7266d60db7432486517a111c76ac8b.html. The problem with
> it is that the function cuts the lines in segments of 10km but it is not
> possible to get the attributes.
>
> 2.      I have also tried the function from this website:
> http://stackoverflow.com/questions/38700246/how-do-i-split-divide-polyline-
> shapefiles-into-equally-length-smaller-segments. The problem is that do not
> cut the segments in 10km, and it seems to cut the segments with random
> lengths.
>
> 3.      On the follwoing website: http://r-sig-geo.2731867.n2.
> nabble.com/split-divide-SpatialLines-sp-into-n-segments-td7583234.html#
> a7583629 propose to divide lines by segments but do not specify how it is
> possible to do in based on the length of the segment.
>
> Is there any function to do this in R? Or does somebody know the solution
> for that?
>
> My data looks like this:
>
> #Script:
>
> path_data <- "C:/R/"
>
> mergedDF_1_DF_short<- shapefile(path_data,"mergedDF_1_DF_short")
>
>
> https://drive.google.com/drive/folders/0B7IbvWhE5JNPT0oxUklpd3ZnRzA?usp=sharing
>
> 	[[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