python Point Coordinate Method for Finding Specific x Value or y Value on a Line

  • 2021-07-13 05:35:56
  • OfStack

The problem can be converted to finding the intersection of a straight line perpendicular to or parallel to the x axis and the y axis


import numpy as np
import shapely.geometry as SG

# A line  list(zip(x,y)) That is the coordinate point on the line list
line = SG.LineString(list(zip(x,y)))

#(1,0) To (1,100) A line of two points 
yline = SG.LineString([(1, 0), (1, 100)])

#or

(0,1) To (100,1) A line of two points 
xline = SG.LineString([(0, 1), (100, 1)])

# The intersection of two lines 
coords = np.array(line.intersection(yline))

# Print out line Coordinate points on this line x Value is 1 Coordinates of 
print(yline)

Related articles: