1

I have a table in a db where I'm running some spatial queries but would like to move this to Python using GeoPandas, shapely etc.

Example:

ST_LineSubstring(geom, 0.005, 0.995)

Which

Computes the line which is the section of the input line starting and ending at the given fractional locations

1 Answer 1

4

You can use shapely.ops.substring.

Usage:

shapely.ops.substring(geom, start_dist, end_dist[, normalized=False])

If the normalized arg is True, the distance will be interpreted as a fraction of the geometry’s length

Example:

from shapely.ops import substring

line_part = substring(geom, 0.005, 0.995, normalized=True)

Not the answer you're looking for? Browse other questions tagged or ask your own question.