I am using QGIS version 2.18.14 with GRASS 7.2.2 to clean up some geometry issues within shp files I have.

I have an initial shapefile “test.shp” which has a field named “area”. The “area” type is REAL with LENGTH = 15 and PRECISION = 7.

I do the following:

  • I load in QGIS (with GRASS7) the file “test.shp” using v.in.ogr (snapping 1.0 and minimal area 10.0) and specify the file name as “test” in the dialog. It all goes well. The file is saved in my GRASS folder with the usual three sub-layers (0 - holes, 1- “fixed” (as I call it), 2 - overlaps).
  • Then I navigate to my GRASS folder and load the “test_1” (the “fixed” sublayer).
  • Now, when I open the attribute table I can see the field “area” and the values shown there are decimal numbers (e.g. 12.345 ... as they should be).

However, if I open the Properties of the “test_1” the field “area” is defined as “double”, but with LENGTH = 20 and PRECISION = 0. When I save the the “test_1” as “test_new.shp”, and then load the “test_new.shp” in the QGIS the field “area” of the “test_new.shp” has lost all the decimal places (e.g. instead of 12.234 is stands 12). If I create a new field “new_area” with LENGTH 15 and PRECISION 7 using the field calculator (“new_area”=1.0 * “area”), I can confirm the loss of precision (i.e. I get 12.000000).

Does anybody have an idea how to go around this?

  • Shapefiles use dBase III+, which uses text to encode floating-point values. If you specify Number (20,0) you will get 18,0 internally. Look as the raw .dbf contents sometime. – Vince Feb 15 '18 at 4:06

I just installed GRASS 7.4 (still not integrated with QGIS it seems) It seems that the above issue is solved in GRASS 7.4.

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.