7

I am creating a thematic map (vector data) with different classes. How to convert this vector map to a raster map, keeping the classification?

  • Are your vector data points, lines or polygons? – Jakob Feb 27 '15 at 12:42
5

You can use the Rasterize function (Raster / Conversion / Rasterize) that will convert a vector file (shapefile) to raster. Just be sure to select the attribute field with your classifications. It's important to note that the attribute field must be numeric. Also, when creating the new raster, you have to set either the raster size (width / height) or pixel resolution.

enter image description here

4

Three other possibilities:

  • Project/Save as image, you'll get a georeferenced image of canvas (limited/screen resolution)
  • In Print composer Composer/Export as image, you will get az image of the set page size, no georeference
  • From the command line use --snapshot switch, huge image can be created with georeference (qgis exit after creating the image, can be used in script files) e.g.

qgis --snapshot my_raster.png --width 4000 --height 3000 my_project.qgs

3

You can use the Interpolation function (Raster > Interpolation > Interpolation) to create a raster map based on multiple classes:

Interpolation

You can choose various settings such as which interpolation method you prefer, how fine a resolution you want the output etc. Note that this is a plugin which I think should already be enabled by default.

Hope this helps!

3

You can use this R script. For example for a map called "Prodes1":

library(rgdal)
library(raster)

Prodes1<-readOGR(dsn="E:/PRODES/PDigital2014_22768_shp", layer="PDigital2014_22768__pol", dropNULLGeometries=TRUE)

Prodes1$Grd_ranks<-rank(Prodes1$mainclass) #Creating a numeric column for rasterize

i<-1
Prodes1$value<-rank(Prodes1$mainclass)
for (i in 1:(length(Prodes1$mainclass))) {
  if (Prodes1$mainclass[i]=="DESFLORESTAMENTO") Prodes1$value[i]<-0 else 
    if (Prodes1$mainclass[i]=="FLORESTA") Prodes1$value[i]<-1 else
      if (Prodes1$mainclass[i]=="HIDROGRAFIA") Prodes1$value[i]<-2 else
        if (Prodes1$mainclass[i]=="NAO_FLORESTA") Prodes1$value[i]<-3 else
          if (Prodes1$mainclass[i]=="NUVEM") Prodes1$value[i]<-4 else
            if (Prodes1$mainclass[i]=="RESIDUO") Prodes1$value[i]<-5 else Prodes1$mainclass[i]<-Prodes1$classe[i])
}                            

#Creating a ROI to receive the raster data
ROI2=raster() 
extent(ROI2)<-extent(Prodes1)
res(ROI2)<-0.002232143
proj4string(ROI2)<-CRS(proj4string(Prodes1))
r<-rasterize(Prodes1, ROI2, "value", fun="first")

#Saving the raster TIFF

writeRaster(r, filename="Prodes.tiff")

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.