Opened 6 years ago

Closed 6 years ago

#7188 closed defect (fixed)

precision loss at conversion to WKT

Reported by: wimned Owned by: warmerdam
Priority: normal Milestone:
Component: OGR_SF Version: unspecified
Severity: normal Keywords:
Cc:

Description

In python program, using osgeo module, using GetGeometryRef() to fetch geometry from a shape file, sometimes loss of precision appears. Typically a round to integer degree appears (out of millions of vectors at some 30 locations was rounded to -108.0, -109.0 or -110.0 degrees).

Setting OGR_WKT_PRECISION, helps but not in all cases:

sample shell text:

echo "WKT,PNTID"> tt_in.csv
echo "\"POINT(-109.999997 32.442461)\",10" >> tt_in.csv
echo "\"POINT(-110.00000020 32.442461)\",10" >> tt_in.csv
ogr2ogr --version
unset OGR_WKT_PRECISION
ogr2ogr -lco GEOMETRY=AS_WKT -f CSV tt_out.csv tt_in.csv
cat tt_out.csv
export OGR_WKT_PRECISION=14
ogr2ogr -lco GEOMETRY=AS_WKT -f CSV tt_out.csv tt_in.csv
cat tt_out.csv

output:

GDAL 2.2.2, released 2017/09/15
WKT,WKT,PNTID
"POINT (-110.0 32.442461)",POINT(-109.999997 32.442461),10
"POINT (-110.0 32.442461)",POINT(-110.0000020 32.442461),10
WKT,WKT,PNTID
"POINT (-109.999997 32.442461)",POINT(-109.999997 32.442461),10
"POINT (-110.0 32.442461)",POINT(-110.0000020 32.442461),10

Change History (1)

comment:1 by Even Rouault, 6 years ago

Resolution: fixed
Status: newclosed

In 41118:

OGRFormatDouble(): add a OGR_WKT_ROUND config option that can be set to FALSE to disable the heuristics that remove trailing 00000x / 99999x patterns (fixes #7188)

Note: See TracTickets for help on using tickets.