Set background extent to raster mask or polygon?

117 views
Skip to first unread message

Michael Smith

unread,
Mar 18, 2021, 9:13:12 PM3/18/21
to Maxent

I'm a complete beginner so apologies in advance...

I'm using the dismo package in R and following a tutorial which tells me how to set a buffer around presence points to produce a background sampling area.

I actually want to use the whole island of New Guinea (as I'm dealing with poorly sampled endemic plants) and I want to make sure background points aren't selected in the sea(!)

I have rasters of the land with sea set as NA (or -9999) or could use a polygon shapefile.

Or perhaps it won't matter, since all my environmental rasters have non-land pixels set to -9999 or -3.400000e+38 ...will MaxEnt ignore those areas?

Thank you for your patience.

Bede-Fazekas Ákos

unread,
Mar 19, 2021, 3:01:53 AM3/19/21
to max...@googlegroups.com
Hello,
you can use sf::st_buffer() for buffering or raster::mask() for masking your environmental/occurrence raster with land/sea raster.
HTH,
Ákos
--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maxent+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maxent/70aa4048-3251-4f98-95b3-66f55cc4aaf5n%40googlegroups.com.

arjun nepal

unread,
Mar 19, 2021, 4:28:09 AM3/19/21
to max...@googlegroups.com
Hello Michael 
Can you share me link to that tutorial 
Beginner here as well

Regards



--
Arjun Nepal (Mr.)
Research Student at Royal University of Bhutan
M.Sc Natural Resource Management (NRM)
Mobile no: +975_17553882
Alternative Email: arjunn...@gmail.com


Michael Smith

unread,
Mar 20, 2021, 5:38:13 AM3/20/21
to Maxent
Hi all,

Thanks for the advice Ákos, I will investigate. I've been using QGIS to get my layers sorted out but I'll develop an R workflow.

What I did in the end was this:

# select one layer of my environmental raster stack and set all the subzero values to NA
sample_raster <- gis[[1]] # my raster brick
    values(sample_raster)[values(sample_raster) < 0] = NA
    
# select random points
      random_points <- sampleRandom(x=sample_raster,
                                    size=length(longlat), # this gives me the same number as my presence records
                                    na.rm=T, #removes the 'NA' points  
                                    sp=T)

...I then call species_model <- dismo::maxent(gis, random_points, various_other_arguments_etc)

Arjun, I have to admit it wasn't exactly a tutorial - but here is the link to the R code I was adapting.

I have had to repurpose this to adapt it to a single island (New Guinea). Let me know if I can help in any way.
Reply all
Reply to author
Forward
0 new messages