4

When creating a new attribute field in QGIS 3.14.15-Pi, these three options are offered for integer numbers but what is the difference between Integer 16bit, 32bit and 64bit in QGIS?

0

2 Answers 2

12

A 16 bit Signed Integer can house a number from −32,768 to 32,767 Unsigned: 0 to 65,535.

A 32 bit (integer type in QGIS) Signed Integer can house a number from −2,147,483,648 to 2,147,483,647 Unsigned: 0 to 4,294,967,295.

A 64 bit (int8 type in QGIS referring to 8 bytes) Signed Integer can house a number from −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 Unsigned: 0 to 18,446,744,073,709,551,615.

Integers in QGIS (3.10+) are Signed unless otherwise stated.

So it depends on the size of the numbers you are storing.

Source: https://en.wikipedia.org/wiki/Integer_(computer_science)

2
  • 3
    And the potential advantage of using the smallest integer type that suits for your data is to save disk space. However, some formats/databases do not really use all 16/32/64 bits for storing small integers.
    – user30184
    Commented Feb 1, 2021 at 12:41
  • Important to keep in mind that for vector attributes in QGIS, the "Type" of "Integer (64 bit)" has a Type name of "int8" referring to 8 bytes. The "Type" of "Integer (32 bit)" has a type name of "integer". Somewhat confusing and I haven't seen it mentioned anywhere
    – Andre Geo
    Commented Nov 21 at 16:58
8

Factors that determine which datatypes are available (not just in) QGIS

Field types are not QGIS specific, but depend on the file/datebase format you use. The options vary for different file formats. Shapefile is an old format, published in 1998 and has several limitations, whereas GeoPackage (used as default file format for vectors since QGIS 3.0) is a newer format, first released in 2014, thus with much lesser limits.

Thus QGIS can't offer the same data types for every file format without violating the requirements for each file format. Also consider that for converting file formats, QGIS uses libraries like GDAL/OGR, so it also relies on these dependencies what QGIS can offer (and what not).

So in principle, it depends on all those software components implicated (Program, libraries, file formats) and it's respective version what is available and what not. Just to make an example, see the comparison between Shapefile and Geopackage:

What you can find in the QGIS documentation about data types

The QGIS documentation for 3.16 reads:

13.2.1.1. Creating a new GeoPackage layer

Supported types are Text data, Whole number (both integer and integer64), Decimal number, Date and Date and time, Binary (BLOB) and Boolean.

13.2.1.2. Creating a new Shapefile layer

Only Decimal number, Whole number, Text data and Date attributes are supported.

General support of data types

See here for the data types supported by Geopackage (scroll down to Table 1. GeoPackage Data Types) - it mentiones between else:

8/16/32/64-bit signed two’s complement integer

See here for the data types supported by Shapefiles from the GDAL documentation:

Only Integer, Integer64, Real, String and Date (not DateTime, just year/month/day) field types are supported. The various list, and binary field types cannot be created

And see this detailed description of the Shapefile format by the Library of Congress:

The Shapefile format stores integer and double-precision numbers. The ESRI Shapefile Technical Description refers to the following types:

Integer: Signed 32-bit integer (4 bytes)
Double: Signed 64-bit IEEE double-precision floating point number (8 bytes)
Floating point numbers must be numeric values.

Screenshot: Geopackage (left), temporary scratch layer (middle), Shapefile (right) - Ganze Zahl means Whole number (my QGIS is in german):

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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