[GIS] Error 4 in rasterizing a polygon shapefile

errorgdalqgis

I'm using QGIS Wien 2.8.1 trying to convert a polygon shapefile to a raster, but I get the following error in a qgis-bin pop-up:

ERROR 4: `' does not exist in the file system,
and is not recognised as a supported dataset name.

I have the 'gdal_rasterize' plug-in installed and I've tried executing this with the data and program files in the same directory (as well as multiple others) to make sure it's not a directory issue.

Any ideas? I'll include the link to the polygon shapefile just in case it might actual be some issue in the data.
http://pubs.usgs.gov/of/2000/of00-444/of00-444_4c.tar.gz

Also, another question: It seems that I can only rasterize upon numeric fields. Is rasterizing upon string fields not possible?

Best Answer

There is not any issue in the data. However, it is very important the metada file in: http://pubs.usgs.gov/of/2000/of00-444/of00-444.met. There, you can observe the projection (EPSG: 4326) of the shapefiles (one is sf-qpys.shp; polygon type) and all classes (58) in, for example, PTYPE field. With this code in the field calculator of QGIS:

CASE 
    WHEN  "PTYPE"  IS 'H2O' THEN 1 
    WHEN  "PTYPE"  IS 'Qa' THEN 2
    WHEN  "PTYPE"  IS 'Qb' THEN 3
    WHEN  "PTYPE"  IS 'Qds' THEN 4
    WHEN  "PTYPE"  IS 'Qf' THEN 5
    WHEN  "PTYPE"  IS 'Qha' THEN 6
    WHEN  "PTYPE"  IS 'Qhay' THEN 7
    WHEN  "PTYPE"  IS 'Qhb' THEN 8
    WHEN  "PTYPE"  IS 'Qhbm' THEN 9
    WHEN  "PTYPE"  IS 'Qhbs' THEN 10
    WHEN  "PTYPE"  IS 'Qhc' THEN 11
    WHEN  "PTYPE"  IS 'Qhdm' THEN 12
    WHEN  "PTYPE"  IS 'Qhds' THEN 13
    WHEN  "PTYPE"  IS 'Qhf' THEN 14
    WHEN  "PTYPE"  IS 'Qhf1' THEN 15
    WHEN  "PTYPE"  IS 'Qhf2' THEN 16
    WHEN  "PTYPE"  IS 'Qhfb' THEN 17
    WHEN  "PTYPE"  IS 'Qhfe' THEN 18
    WHEN  "PTYPE"  IS 'Qhff' THEN 19
    WHEN  "PTYPE"  IS 'Qhfp' THEN 20
    WHEN  "PTYPE"  IS 'Qhfy' THEN 21
    WHEN  "PTYPE"  IS 'Qhl' THEN 22
    WHEN  "PTYPE"  IS 'Qhl1' THEN 23
    WHEN  "PTYPE"  IS 'Qhl2' THEN 24
    WHEN  "PTYPE"  IS 'Qhly' THEN 25
    WHEN  "PTYPE"  IS 'Qht' THEN 26
    WHEN  "PTYPE"  IS 'Qht1' THEN 27
    WHEN  "PTYPE"  IS 'Qht2' THEN 28
    WHEN  "PTYPE"  IS 'Qhty' THEN 29
    WHEN  "PTYPE"  IS 'Qhty1' THEN 30
    WHEN  "PTYPE"  IS 'Qhty2' THEN 31
    WHEN  "PTYPE"  IS 'Q1' THEN 32
    WHEN  "PTYPE"  IS 'Qmt' THEN 33
    WHEN  "PTYPE"  IS 'Qmt1' THEN 34
    WHEN  "PTYPE"  IS 'Qmt2' THEN 35
    WHEN  "PTYPE"  IS 'Qmt3' THEN 36
    WHEN  "PTYPE"  IS 'Qmt4' THEN 37
    WHEN  "PTYPE"  IS 'Qoa' THEN 38
    WHEN  "PTYPE"  IS 'Qoa1' THEN 39
    WHEN  "PTYPE"  IS 'Qoa2' THEN 40
    WHEN  "PTYPE"  IS 'Qof' THEN 41
    WHEN  "PTYPE"  IS 'Qof1' THEN 42
    WHEN  "PTYPE"  IS 'Qof2' THEN 43
    WHEN  "PTYPE"  IS 'Qop' THEN 44
    WHEN  "PTYPE"  IS 'Qot' THEN 45
    WHEN  "PTYPE"  IS 'Qpa' THEN 46
    WHEN  "PTYPE"  IS 'Qpb' THEN 47
    WHEN  "PTYPE"  IS 'Qpf' THEN 48
    WHEN  "PTYPE"  IS 'Qpt' THEN 49
    WHEN  "PTYPE"  IS 'Qt' THEN 50
    WHEN  "PTYPE"  IS 'ac' THEN 51
    WHEN  "PTYPE"  IS 'ads' THEN 52
    WHEN  "PTYPE"  IS 'af' THEN 53
    WHEN  "PTYPE"  IS 'afbm' THEN 54
    WHEN  "PTYPE"  IS 'alf' THEN 55
    WHEN  "PTYPE"  IS 'br' THEN 56
    WHEN  "PTYPE"  IS 'gq' THEN 57
    WHEN  "PTYPE"  IS 'nm' THEN 58
END

you can get one field (PTYPE_NUM) with numeric codes for rasterizing (see next image):

enter image description here

Assuming that each degree at the equator represents 111,319.9 metres (http://en.wikipedia.org/wiki/Decimal_degrees), one map resolution of 30 x 30 meters is approximately 0.00027 x 0.00027 degrees (you can also work direcly in meters with UTM Zone Number 10, datum NAD27; see metadata). So, by using this data in our gdal_rasterize command (Raster -> Conversion -> Rasterize):

enter image description here

The result is:

enter image description here

The pseudocolor image has 58 classes where blue color is class 1 (H2O, water).