<div dir="ltr"><table><tbody><tr><td class=""><div class="">
<span class=""></span><br>
</div>
</td>
<td class="">
<div>
<div class="">
<p>I want to determine the shortest distance between a point and
a line. I use the following Python script to do so. If I compare the
result of the script with the result of ArcMap's Near Analysis, I get a
completely different results. The shapefiles are in the CRS
GCS_North_American_1983 and projected with Albers. What could be the
reason for the difference?</p>
<pre style class=""><code><span class="">import</span><span class=""> ogr
driver </span><span class="">=</span><span class=""> ogr</span><span class="">.</span><span class="">GetDriverByName</span><span class="">(</span><span class="">'ESRI Shapefile'</span><span class="">)</span><span class="">
lineshp </span><span class="">=</span><span class=""> driver</span><span class="">.</span><span class="">Open</span><span class="">(</span><span class="">'U:/My Documents/Tool/shp/line.shp'</span><span class="">,</span><span class=""> </span><span class="">0</span><span class="">)</span><span class="">
linelyr </span><span class="">=</span><span class=""> lineshp</span><span class="">.</span><span class="">GetLayer</span><span class="">()</span><span class="">
pointshp </span><span class="">=</span><span class=""> driver</span><span class="">.</span><span class="">Open</span><span class="">(</span><span class="">'U:/My Documents/Tool/shp/point.shp'</span><span class="">,</span><span class=""> </span><span class="">0</span><span class="">)</span><span class="">
pointlyr </span><span class="">=</span><span class=""> pointshp</span><span class="">.</span><span class="">GetLayer</span><span class="">()</span><span class="">
line </span><span class="">=</span><span class=""> linelyr</span><span class="">.</span><span class="">GetNextFeature</span><span class="">()</span><span class="">
point </span><span class="">=</span><span class=""> pointlyr</span><span class="">.</span><span class="">GetNextFeature</span><span class="">()</span><span class="">
line_geom </span><span class="">=</span><span class=""> line</span><span class="">.</span><span class="">GetGeometryRef</span><span class="">()</span><span class="">
point_geom </span><span class="">=</span><span class=""> point</span><span class="">.</span><span class="">GetGeometryRef</span><span class="">()</span><span class="">
dist </span><span class="">=</span><span class=""> point_geom</span><span class="">.</span><span class="">Distance</span><span class="">(</span><span class="">line_geom</span><span class="">)</span><span class="">
print dist<br><br>Thanks ahead!<br><br>Uli<br></span></code></pre>
</div></div></td></tr></tbody></table></div>