Skip to content

Instantly share code, notes, and snippets.

@jccartwright
Created April 30, 2015 04:45
Show Gist options
  • Save jccartwright/f5931e478beec1dc224f to your computer and use it in GitHub Desktop.
Save jccartwright/f5931e478beec1dc224f to your computer and use it in GitHub Desktop.
extract points along a line using JTS
import com.vividsolutions.jts.linearref.LengthIndexedLine
import com.vividsolutions.jts.io.WKTReader
def reader = new WKTReader()
def line = reader.read("LINESTRING(10 10, -10 -10)")
def lil = new LengthIndexedLine(line)
def increment = 2
def index = 0
while (index <= line.length) {
println lil.extractPoint(index)
index += increment
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment