You may change the field type by using the 'cast' sql option during the ogr2ogr conversion, like 'select cast(DEPTH as numeric(8,2)) from SOUNDG'<br><br>for more info see: <a href="http://www.gdal.org/ogr/ogr_sql.html">http://www.gdal.org/ogr/ogr_sql.html</a><br>
<br>Best regards,<br><br>Tamas<br><br><br><div style="visibility: hidden; display: inline;" id="avg_ls_inline_popup"></div><style type="text/css">#avg_ls_inline_popup { position:absolute; z-index:9999; padding: 0px 0px; margin-left: 0px; margin-top: 0px; width: 240px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 13px;}</style><br>
<div class="gmail_quote">2010/7/21 easyl <span dir="ltr"><<a href="mailto:thlin.box@gmail.com">thlin.box@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
How can I let ogr2ogr keep, change or determine real number precision?? when<br>
converting shapefiles.<br>
<br>
ogr2ogr changes the representation (or precision) of a numeric attributes.<br>
<br>
For example, I use ogr2ogr to convert S-57 files to shapefiles.<br>
<br>
The layer "SOUNDG" of S-57 represents the water depth in a nautical map. It<br>
is encoded in a little bit tricky way.<br>
However GDAL can handle "SOUNDG" layer by setting OGR_S57_OPTIONS so that<br>
SOUNDG will be treated as points with generated DEPTH attributes.<br>
> export OGR_S57_OPTIONS=SPLIT_MULTIPOINT=ON,ADD_SOUNDG_DEPTH=ON<br>
<br>
then I use ogrinfo to inspect original data source<br>
> ogrinfo shape.000 SOUNDG<br>
...<br>
OGRFeature(SOUNDG):7655<br>
...<br>
DEPTH (Real) = 2.1<br>
POINT (21.8520083 63.593027300000003 2.1)<br>
...<br>
<br>
DEPTH "2.1" means that the location from (21.8520083 63.593027300000003) has<br>
2.1 meter water depth.<br>
<br>
Now I try to convert it to shapefile (layer: SOUNDG, type: POINT)<br>
> ogr2ogr -skipfailure -append -f "ESRI Shapefile" out shape.000 -nlt<br>
POINT SOUNDG<br>
<br>
Then I use ogrinfo to inspect converted shapefiles<br>
> ogrinfo out/SOUNDG.shp SOUNDG<br>
...<br>
OGRFeature(SOUNDG):0<br>
...<br>
DEPTH (Real) = 2.100000000000000<br>
POINT (21.8520083 63.593027300000003)<br>
...<br>
Here is the problem. The DEPTH attributes has now higher precision. It is<br>
numerically OK.<br>
But when I try to use this attribute in MapServer as LABELITEM, I get a text<br>
"2.100000000000000" instead of "2.1".<br>
<br>
AFAIK, in MapServer the numeric attributes cannot be manipulated for serving<br>
a label text. What I can do is to keep the number representation when<br>
running ogr2ogr.<br>
<br>
How can I do that? or any other solution?<br>
<br>
Thanks in advance.<br>
<font color="#888888"><br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/determine-real-number-precision-with-ogr2ogr-tp5321136p5321136.html" target="_blank">http://osgeo-org.1803224.n2.nabble.com/determine-real-number-precision-with-ogr2ogr-tp5321136p5321136.html</a><br>
Sent from the GDAL - Dev mailing list archive at Nabble.com.<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>
</font></blockquote></div><br>