0

I am trying to do species distribution mapping in R for invasive oyster species (marine). With the code that I am using, it will plot points only on land (ext= geographic.extent). I cannot find other "extent" options for example marine.extent or a way to do -geographic.extent so that it would be everything BUT the currently plotted area.

# Randomly sample points (same number as our observed points)
background <- randomPoints(mask = mask,     # Provides resolution of sampling points
                           n = nrow(obs.data),      # Number of random points
                           ext = geographic.extent, # Spatially restricts sampling
                           extf = 1.25)             # Expands sampling a little bit
# Plot the base map
plot(wrld_simpl, 
     xlim = c(0, 30), #north and baltic sea
     ylim = c(50, 70),
     axes = TRUE, 
     col = "grey95",
     main = "Presence and pseudo-absence points")

# Add the background points
points(background, col = "grey30", pch = 1, cex = 0.75)

All plotted points on land not marine area

benson23
  • 16,369
  • 9
  • 19
  • 38
amerray
  • 11
  • 1

1 Answers1

0

geographic.extent is a variable that you supply. It is probably created in your own code, or else by a package you load. Can you edit your question and show what it is (print it)?

To only sample points from certain areas, use the mask argument (as you do). In your case all land areas should be NA and all marine areas should not be NA.

Robert Hijmans
  • 40,301
  • 4
  • 55
  • 63