Thursday, 17 September 2015

qgis - How to define the type of a field in the field calculator so that the rasterize (vector to raster) tool recognize it?



I have a shapefile (polygon) that I want to rasterize by an attribute but the rasterize tool does not recognize the right field. When I create a new field using the field calculator it does not matter what type I choose (integer, real, ...) the result is qlonglong (integer64), a type that the rasterize tool apparently does not recognize.



Answer



Here is a list of fields that contains different type of fields: integer, String, and qlonglong (integer64).


enter image description here


If you access the Rasterize tool from Raster -> Conversion -> Rasterize (Vector to raster) you will see only the fields that are integer type.


enter image description here


To get integer type not qlonglong (integer64), the length should be from 1 to 9 when you define a new field, as you can see below:


enter image description here


However, if you accessed the Rasterize (Vector to raster) tool from Processing toolbox -> GDAL/OGR -> [GDAL] Conversion -> Rasterize (Vector to raster), you will get every type in the attribute table even the string type, as you can see below:


enter image description here



My recommendation is to use the rasterize tool from Processing toolbox.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...