[R-sig-Geo] count points greater than in a raster

Ahmadou Dicko dicko.ahmadou at gmail.com
Wed Oct 5 19:57:41 CEST 2016


Hi,

I don't see any need to create a custom function for that, you can just
manipulate the final raster as requested.

pop <- read.table("allGeo.tsv", header=TRUE, stringsAsFactors=FALSE)
head(pop)
r2 = raster (ncol=500,nrow=1000)
pr<-raster::rasterize(pop, r2, fun='count', cex=0.6)
cropbox2 <-c(-178,-49,18, 71)
pr2 <- crop(pr, cropbox2)
pr2[pr2 >= 1e5] <- 1e5

Hope it helps


On Wed, Oct 5, 2016 at 7:50 PM, Lindsie McCabe <lma243 at nau.edu> wrote:

> Hi All,
>
> I am creating a raster map of insect occurrence records, right now I have
> if counting up the number of occurrence points based on the pixel area.
>
> However because there is one area that is highly abundant in occurrence
> records it is saturating the rest of the map.
>
> What I would like to do is call a function in R that says if count is
> grater the 100,000 records count as 100,000.
>
> This is the code I am working with now:
> pop <- read.table("allGeo.tsv", header=TRUE, stringsAsFactors=FALSE)
> head(pop)
> r2 = raster (ncol=500,nrow=1000)
> pr<-raster::rasterize(pop, r2, fun='count', cex=0.6)
> cropbox2 <-c(-178,-49,18, 71)
> pr2 <- crop(pr, cropbox2)
> pr2
> plot(pr2)
>
>
> Thank you,
>
>
> --
> *Lindsie McCabe*
> PhD Student
> Department of Biology
> Merriam Powell Center for Environmental Research
> Northern Arizona University
>
>         [[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
>



-- 
Ahmadou H. DICKO, PhD
Data hacker and climate change economist
Post-doctoral researcher
CIRAD - UMR15 CIRAD/INRA Control of exotic and emerging diseases
email : ahmadou-hamady.dicko at cirad.fr <ahmadou.dicko at ucad.edu.sn>
twitter : @dickoah
github : github/dickoa <https://github.com/dickoa>
portable: +33 7 68 16 11 58

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list