At 3.8.3, when I Export > Save As a Geopackage point layer to a shapefile, fields with type = double are output with 15(!!!) significant digits. Here are the before and after field widths:

Type:    double
Length:   10
Precision:  2

Type:    double
Length:   23
Precision: 15

Furthermore, the output values are modified by a slight amount. Here are some examples:

Input    Output
150.62   150.620000000000005
150.51   150.509999999999991
221.86   221.860000000000014

How do I maintain the source length and precision?


Based on the comment kindly provided by user30184, the QGIS shapefile output that my OP described appears - unfortunately - to be the default action.

Now I'm curious about the passage that user30184 quoted, particularly the phrase "...Real (floating point) fields without an explicit width..." This implies that my fields did not have explicit widths. My new question is, how do I make my real field widths explicit, either by modifying the source layer, or in the GDAL output process, or some other method?

  • Precision value seems to be close to GDAL default value gdal.org/drivers/vector/shapefile.html Real (floating point) fields without an explicit width are treated as width 24 with 15 decimal places of precision.. – user30184 Nov 14 '19 at 8:14
  • Thanks for the link, that was an interesting read. I'll updated my OP accordingly. – Stu Smith Nov 14 '19 at 17:12
  • You can use the Vector - Table - Refactor Fields tool to change field attributes like precision. When adding a new field using the Field Calculator you tell it the field type, length and precision. – johns Nov 14 '19 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.