Uli, <div><br></div><div>You might want to elaborate on in what ways the results differ.  Perhaps for a concrete example pair of geometries.  The GDAL/OGR Distance is going to give planar distance in "decimal degrees" if everything is in geographic coordinates without regard to ellipsoidal geometries.  I suspect the ArcGIS algorithm is actually giving a distance in meters - possibly for the great circle path from the closest points.  If that is what you need, a different approach will be needed.</div>
<div><br></div><div>Best regards,</div><div>Frank<br><br><div class="gmail_quote">On Wed, Mar 6, 2013 at 2:49 PM, Uli Strötz <span dir="ltr"><<a href="mailto:ustroetz@gmail.com" target="_blank">ustroetz@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><table><tbody><tr><td><div>
    <span></span><br>
       

 
</div>

            </td>
            
<td>
<div>
    <div>
        <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><code><span>import</span><span> ogr

driver </span><span>=</span><span> ogr</span><span>.</span><span>GetDriverByName</span><span>(</span><span>'ESRI Shapefile'</span><span>)</span><span>

lineshp </span><span>=</span><span> driver</span><span>.</span><span>Open</span><span>(</span><span>'U:/My Documents/Tool/shp/line.shp'</span><span>,</span><span> </span><span>0</span><span>)</span><span>
linelyr </span><span>=</span><span> lineshp</span><span>.</span><span>GetLayer</span><span>()</span><span>

pointshp </span><span>=</span><span> driver</span><span>.</span><span>Open</span><span>(</span><span>'U:/My Documents/Tool/shp/point.shp'</span><span>,</span><span> </span><span>0</span><span>)</span><span>
pointlyr </span><span>=</span><span> pointshp</span><span>.</span><span>GetLayer</span><span>()</span><span>

line </span><span>=</span><span> linelyr</span><span>.</span><span>GetNextFeature</span><span>()</span><span>
point </span><span>=</span><span> pointlyr</span><span>.</span><span>GetNextFeature</span><span>()</span><span>

line_geom </span><span>=</span><span> line</span><span>.</span><span>GetGeometryRef</span><span>()</span><span>
point_geom </span><span>=</span><span> point</span><span>.</span><span>GetGeometryRef</span><span>()</span><span>

dist </span><span>=</span><span> point_geom</span><span>.</span><span>Distance</span><span>(</span><span>line_geom</span><span>)</span><span>

print dist<br><br>Thanks ahead!<span class="HOEnZb"><font color="#888888"><br><br>Uli<br></font></span></span></code></pre>

    </div></div></td></tr></tbody></table></div>
<br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>---------------------------------------+--------------------------------------<br>
I set the clouds in motion - turn up   | Frank Warmerdam, <a href="mailto:warmerdam@pobox.com" target="_blank">warmerdam@pobox.com</a><br>light and sound - activate the windows | <a href="http://pobox.com/~warmerdam" target="_blank">http://pobox.com/~warmerdam</a><br>
and watch the world go round - Rush    | Geospatial Software Developer<br>
</div>