擅长:python、mysql、java
<p>您描述的GIS术语是<a href="https://en.wikipedia.org/wiki/Linear_referencing" rel="noreferrer">linear referencing</a>,和<a href="https://shapely.readthedocs.io/en/latest/manual.html#linear-referencing-methods" rel="noreferrer">Shapely has these methods</a>。</p>
<pre><code># Length along line that is closest to the point
print(line.project(p))
# Now combine with interpolated point on line
np = line.interpolate(line.project(p))
print(np) # POINT (5 7)
</code></pre>
<hr/>
<p>另一种方法是使用<a href="https://shapely.readthedocs.io/en/latest/manual.html#nearest-points" rel="noreferrer">^{<cd1>}</a>:</p>
<pre><code>from shapely.ops import nearest_points
np = nearest_points(line, p)[0]
print(np) # POINT (5 7)
</code></pre>
<p>它提供了与线性引用技术相同的答案,但可以从更复杂的几何输入(如两个多边形)确定最近的点对。</p>