[R-sig-Geo] Rasterize SpatialPolygons in R is ignoring small values

Tiago Castro Silva tiago.castro.icmbio at gmail.com
Fri Sep 18 15:20:09 CEST 2015


I'm trying to convert a polygon shapefile with small values. Values from
the colunm propEmp range from 0.000002 to 0.119419. This is my attempt:

# Load shapefile
emp_planejado <- shapefile("./planejado/7_wgs/emp_planejado.shp")
# Load raster model
r_bioma<- raster("./_GRID/grid_caatinga_disol_64bit.tif")
# List values from tipologia field
tipologia<-unique(emp_planejado$tipologia)

for (tp in tipologia){# Select features for each value in tipologia
tipo<- emp_planejado[emp_planejado$tipologia==tp,]
# Rasterize
r_pol <- rasterize(tipo,r_bioma,field="propEmp",background=NA,mask=F)
# Merge
raster_merge <- merge(r_pol,r_bioma)
# Save raster
writeRaster(raster_merge,filename=
paste0("./planejado/8_raster/",tp,"_planejado"),format="GTiff",NAflag=-9999,overwrite=TRUE)
 }

r_bioma is a 64bit with double precision raster with all pixel values equal
to 0.

There is no overlap between features of this polygon, just boundary
touching, so I did not use funas an argument of rasterize.

After rasterize, when I check the minValue and maxValue from r_pol, instead
of getting 0.000002 and 0.119419, I get 0.08687903 and 0.1140689.

I don't know where the problem is. Could you help me?

Thanks for your attention.

Tiago

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list