6

I'm working on a shapefile on QGIS 2.8.6, on Debian Jessy. Its attribute table contains two columns (real 8,6) for longitude and latitude coordinates. When working from QGIS I'm able to write normal values, i.e :

  • longitude;latitude
  • 1.153303;43.834765
  • 1.136567;43.822574

However when I try to open the dbf file with LibreOffice Calc, strange things occur : the data type is set to "N,9,6" instead of 8,6 and about 80% of the values are rounded, i.e. :

  • longitude;latitude
  • 1.000000;43.000000
  • 0.000000;43.000000

This phenomenon is the same when I try with OpenOffice or Microsoft Excel (with one exception : with OpenOffice I was able to get the correct values but only once).

Same goes when I try to save the shapefile from QGIS in a CSV file ; values get "lost in translation".

This seems totally random to me, as I'm unable to explain this behaviour. I tried copying values from longitude and latitude columns in text columns in QGIS, and then opening the dbf : in this case the original longitude and latitude all appear with the correct value (however with real 9,6 and 7,6 this time!).

Does someone have an explanation ? Does this come from QGIS itself or is this a problem when reading the dbf file ?

Edit : I wonder if the problem could come from the decimal mark ? I used the comma which is the decimal mark used in my country but it seems that some softwares are waiting points. Could it be a reason ?

Edit2 : I found a way to export a CSV of the attribute table and getting the correct values, by using the MMQGIS plugin (as proposed in this answer), which allows you to explicitely state the decimal mark. It works where the native option in QGIS didn't.

This is not an explanation nor a solution to my initial problem though, but I guess it could be useful to some people.

  • Have you tried opening in LibreOffice Base rather than Calc? I can't get that to work at all on my setup, but it seems to be a common answer on the LibreOffice forum for issues like this. Bear in mind LibreOffice is a fork of OpenOffice, so something that works in one might not work in the other. – Steven Kay Aug 22 '16 at 21:02
  • Just tried your advice. I managed to import the dbf file with LibreOffice Base, however the table give the same result : some coordinates are rounded instead of staying in real format. The attribute table in QGIS still shows the normal values. – J-G1234 Aug 23 '16 at 7:08
2

Your edit might lead into the right direction.

In the attribute table and field calculator, always use decimal points. Same applies to delimited text files. This is regardless of the locale in Settings -> Options. Stangely, other parts of QGIS like the Georeferencer accept decimal commas, transforming decimal points automatically to commas as well.

Libre Office always uses your OS locale, using decimal comma. This is nasty when you export from Libre Office to CSV in order to import to QGIS. As a workaround, I always use semicolons or blanks as separator, and do a Search and Replace from comma to point in Notepad++ before feeding to QGIS. The other way round, LibreOffice turns decimal points into commas.

  • The strange thing is, when I'm on the attribute table of QGIS and add values, QGIS automatically gives me values with points, regardless of the OS locale (which is commas as I just checked in Calc). Actually I'm forced to use the point, as pressing the comma key doesn't even work (same goes for the decimal key on the numeric keypad : it gives me a point). So I guess my problem comes from LibreOffice trying to get real values with points whereas it expects commas, thus messing things up. – J-G1234 Aug 23 '16 at 13:47
  • Editing a dbf file in LibreOffice is not recommended. You get messed everything up if you re-sort or delete the lines. – AndreJ Aug 23 '16 at 14:12

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.