You can use this R script
You will need these packages:
- library(rgdal)
- library (raster)
. For example for a map called "Prodes1":
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")
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")