[gdal-dev] determine real number precision with ogr2ogr
Tamas Szekeres
szekerest at gmail.com
Wed Jul 21 18:15:17 EDT 2010
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'
for more info see: http://www.gdal.org/ogr/ogr_sql.html
Best regards,
Tamas
2010/7/21 easyl <thlin.box at gmail.com>
>
> How can I let ogr2ogr keep, change or determine real number precision??
> when
> converting shapefiles.
>
> ogr2ogr changes the representation (or precision) of a numeric attributes.
>
> For example, I use ogr2ogr to convert S-57 files to shapefiles.
>
> The layer "SOUNDG" of S-57 represents the water depth in a nautical map. It
> is encoded in a little bit tricky way.
> However GDAL can handle "SOUNDG" layer by setting OGR_S57_OPTIONS so that
> SOUNDG will be treated as points with generated DEPTH attributes.
> > export OGR_S57_OPTIONS=SPLIT_MULTIPOINT=ON,ADD_SOUNDG_DEPTH=ON
>
> then I use ogrinfo to inspect original data source
> > ogrinfo shape.000 SOUNDG
> ...
> OGRFeature(SOUNDG):7655
> ...
> DEPTH (Real) = 2.1
> POINT (21.8520083 63.593027300000003 2.1)
> ...
>
> DEPTH "2.1" means that the location from (21.8520083 63.593027300000003)
> has
> 2.1 meter water depth.
>
> Now I try to convert it to shapefile (layer: SOUNDG, type: POINT)
> > ogr2ogr -skipfailure -append -f "ESRI Shapefile" out shape.000 -nlt
> POINT SOUNDG
>
> Then I use ogrinfo to inspect converted shapefiles
> > ogrinfo out/SOUNDG.shp SOUNDG
> ...
> OGRFeature(SOUNDG):0
> ...
> DEPTH (Real) = 2.100000000000000
> POINT (21.8520083 63.593027300000003)
> ...
> Here is the problem. The DEPTH attributes has now higher precision. It is
> numerically OK.
> But when I try to use this attribute in MapServer as LABELITEM, I get a
> text
> "2.100000000000000" instead of "2.1".
>
> AFAIK, in MapServer the numeric attributes cannot be manipulated for
> serving
> a label text. What I can do is to keep the number representation when
> running ogr2ogr.
>
> How can I do that? or any other solution?
>
> Thanks in advance.
>
>
>
>
>
> --
> View this message in context:
> http://osgeo-org.1803224.n2.nabble.com/determine-real-number-precision-with-ogr2ogr-tp5321136p5321136.html
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100722/e8ffa016/attachment.html
More information about the gdal-dev
mailing list