R: Why are my created pseudo absences not staying within my county mask? -
i'm trying create pseudo absences in r presence-only species distribution model in colorado, usa. project not entire state of co - several selected counties within study area. however, having difficulties restricting pseudo absence data (calculated in r) counties' spatial extent. here's code i've used far:
counties<-shapefile("location of shapefile") us.bbox2 <- bbox(counties) xlim <- c(min(us.bbox2[1,1]),max(us.bbox2[1,2])) ylim <- c(min(us.bbox2[2,1]),max(us.bbox2[2,2])) plot(counties, xlim=xlim, ylim=ylim, col='cornsilk') box() axis(1, las=1) axis(2, las=1) mask2<-raster(counties) nrow(mask2)<-13145 ncol(mask2)<-14274 #default of imported shapefile 10x10 units, adjusted... #...the rows , columns match existing 30x30m raster of area set.seed(1963) #setting seed pseudo absences bg<- randompoints(mask2,100) points(bg, cex=0.1)
i tried creating mask of counties prior creating pseudo absences, loosely following instructions species distribution modeling r package info (page 19). imported own shapefile clipped counties, in utm nad 83 format, , able plot presence-only data. however, this county map looks like. can see, have pseudo absences outside boundaries of counties. novice in r , coding, if please, let me know i'm doing wrong code , how best modify existing code restrict pseudo absences study area. thank you!
Comments
Post a Comment