[gdal-dev] OGR distance different than in ArcGIS
Uli Strötz
ustroetz at gmail.com
Wed Mar 6 14:49:53 PST 2013
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?
import ogr
driver = ogr.GetDriverByName('ESRI Shapefile')
lineshp = driver.Open('U:/My Documents/Tool/shp/line.shp', 0)
linelyr = lineshp.GetLayer()
pointshp = driver.Open('U:/My Documents/Tool/shp/point.shp', 0)
pointlyr = pointshp.GetLayer()
line = linelyr.GetNextFeature()
point = pointlyr.GetNextFeature()
line_geom = line.GetGeometryRef()
point_geom = point.GetGeometryRef()
dist = point_geom.Distance(line_geom)
print dist
Thanks ahead!
Uli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130306/d12703b0/attachment.html>
More information about the gdal-dev
mailing list