[R-sig-Geo] Add +1 to current value of a cell in a raster in R

Ben Tupper btupper at bigelow.org
Mon Jul 11 18:33:57 CEST 2016


Hi Giacomo,

I am interested to know which you find fastest - perhaps you could let us know some timing results?

Thanks,
Ben

> On Jul 11, 2016, at 12:21 PM, Giacomo May <Giacomo_May94 at gmx.de> wrote:
> 
> Thanks for all the replies. In case anyone is interested, I asked the same question on stackexchange and got the following answer:
> 
> library(dplyr)
> cel <- data_frame(cell = vec)
> tab <- cel %>% group_by(cell) %>% summarize(val = n())
> ## update your raster
> r[tab$cell] <- tab$val
> 
> I will try the soultions you guys suggested as well, thanks a lot again !
> Best,
> Giacomo
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

Report Gulf of Maine jellyfish sightings to jellyfish at bigelow.org or tweet them to #MaineJellies -- include date, time, and location, as well as any descriptive information such as size or type.  Learn more at https://www.bigelow.org/research/srs/nick-record/nick-record-laboratory/mainejellies/


	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list