0

Today I came across a very strange behavior of QGIS. Maybe someone knows what's going on?

I have a table with two fields which are defined as Double, with a Length of 20 and a Precision of 0. Some sample values:

8159080177
8159080742
8159080008
...

The format by the way is shape. Exporting a selection of the features results in a table that has same definitions as stated above but all values for the two columns are

-2147483648  
-2147483648  
-2147483648  
...

I get the same values when I read the features with python using ogr's <feature>.GetFieldAsInteger('<fieldname>'). Reading it as a string returns the correct value.

What is happening here?

  • integer overflow – underdark Mar 26 '14 at 9:52
  • Ok, but does QGIS convert the values when writing it to a new shapefile!? – LarsVegas Mar 26 '14 at 9:56
  • Could you describe exactly which steps you take to "Exporting a selection of the features results in a table that has same definitions " – underdark Mar 26 '14 at 10:16
  • Sure. Select a couple of features manually using 'select by rectangle' tool, save selection as dialog, save as shapefile. – LarsVegas Mar 26 '14 at 10:24
1

According to http://www.gdal.org/ogr/drv_shapefile.html, GDAL and QGIS only create field types Integer, Real, String and Date.

So if your data was defined as Double by some other software, QGIS has to do some converting.

Integer is obiously wrong, so manual conversion with the field calculator to string would be the best option.

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.