1

I have a shapefile of river segments that I've imported into R. The segments range in length from 5-115km. I want to split the segments that are over 10km into 10km chunks. So I use st_segmentize. But this doesn't actually split a long line into multiple new shorter lines, which is what I want... Is there a way to do this? I think st_segmentize just adds vertices every 10km. So I just need to split the lines at the vertices.

Code so far:

library("sf")
rivers = st_read("./YukonMain4_copy.shp", layer = 'YukonMain4_copy')
seg = st_segmentize(rivers, units::set_units(10,km))

Thanks for your help!

Spacedman
  • 92,590
  • 12
  • 140
  • 224
Ana
  • 421
  • 3
  • 12
  • Can you share a minimal example dataset that replicates your problem? See this post for help: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Phil Dec 08 '17 at 17:00
  • Hi Phil, you got it. I'll work on creating an example data set, but I'm very new to 'sf' so it might take a while (so standby for that)! The problem is that I don't know how to split large line segments into smaller line segments, and I'm wondering if folks know of a function to do this. – Ana Dec 08 '17 at 17:06
  • I don't off the top of my head, but if you have an small shapefiles of lines to play with I can test a few things. Of course, someone might be able to just say, "it's function `x`", but it's always best to try and provide a minimal reproducible example – Phil Dec 08 '17 at 17:09
  • Ok, so I made a sample shapefile that you could download, but I don't see a place to upload it..... I am really struggling to figure out a way to write code that makes a sample line for you to test with. I'll keep on it though. I appreciate the help. – Ana Dec 08 '17 at 17:21
  • Try posting gis questions on http://gis.stackexchange.com instead of here. – Spacedman Dec 08 '17 at 17:37
  • I'll give that a go instead, thanks. – Ana Dec 08 '17 at 17:41

0 Answers0