wc

# Shapely point distance

May 15, 2012 · # distance_from_shore.py: compute true distance between points # and closest geometry. # shaun walbridge, 2012.05.15 # TODO: no indexing used currently, could stand if performance needs # improving (currently runs in ~1.5hr for 13k points) from geopy import distance: from osgeo import ogr: from shapely. geometry import Point, MultiPolygon.

Example using OGR and Shapely to compute true distances between geometries and points. - true-distance-to-shore.py Skip to. distance_array = np.sqrt(np.sum((points_array - origin) ** 2, 1)) And retrieve the points where the distance is smaller than max_distance. near_points = points_array[distance_array < max_distance] To compare the numpy solutions to the other answers in terms of speed I timed the answers for the same set of 1e6 random points: The. The returned distance is based on. # Calculate the distance between point1 and point2 dist = point1. distance (point2) # Print out a nicely formatted info message print (f "Distance between the points is {dist} units") Distance between the points is 29.723559679150142 units.

def cut_in_two(line): """ Cuts input line into two lines of equal length Parameters ----- line : shapely.LineString input line Returns ----- list (LineString, LineString, Point) two lines and the middle point cutting input line """ from shapely.geometry import Point, LineString # Get final distance value distance = line.length/2 # Cuts a line in two at a distance from its starting point if distance <= 0.0 or distance >= line.length: return [LineString(line)] coords = list(line.coords) for i.

xc