[R-sig-Geo] Rasterize SpatialPolygons in R is ignoring small values
Thierry Onkelinx
thierry.onkelinx at inbo.be
Fri Sep 18 15:32:33 CEST 2015
Please don't post in HTML and don't cross post
(http://stackoverflow.com/questions/32652814/rasterize-spatialpolygons-in-r-is-ignoring-small-values).
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
To call in the statistician after the experiment is done may be no
more than asking him to perform a post-mortem examination: he may be
able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does
not ensure that a reasonable answer can be extracted from a given body
of data. ~ John Tukey
2015-09-18 15:20 GMT+02:00 Tiago Castro Silva <tiago.castro.icmbio at gmail.com>:
> 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]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list