[gdal-dev] OGR distance different than in ArcGIS
Uli Strötz
ustroetz at gmail.com
Wed Mar 6 15:59:02 PST 2013
Hi Frank,
The distance is according to ArcGIS 500m. According to Python(OGR)
29215.31. I was thinking the same, that GDAL gives the distance according
to the Geographic Coordinate System. Is there a way it uses the units of
the Projected Coordinate System (which would be meters)? Or do you know of
another workaround to get the result in meters?
Best,
Uli
2013/3/6 Frank Warmerdam <warmerdam at pobox.com>
> Uli,
>
> 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.
>
> Best regards,
> Frank
>
> On Wed, Mar 6, 2013 at 2:49 PM, Uli Strötz <ustroetz at gmail.com> wrote:
>
>>
>> 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
>>
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>
>
>
> --
>
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up | Frank Warmerdam,
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush | Geospatial Software Developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130306/0a79ddc4/attachment-0001.html>
More information about the gdal-dev
mailing list