[R] How to get rid of extra areas on spatial data map

Changyou Sun csun at CFR.MsState.Edu
Fri Apr 16 20:19:03 CEST 2010

Hello All,

I am using "sp" and "maps" libraries to have a map for some fire data.
The region covered is Mississippi State in the US. Then I would like to
add a layer of ecoregion on the top (omenrik layer from
nationalatlas.gov). The problem is that the ecoregion layer is larger
than the state boundary. How can I get rid of these ecoregion areas out
of MS state?

The code is like this:

# Both data.fire and data.ecoregion are class of
# Every fire is within the state boundary so it looks nice.
# Some ecoregions go beyond the state boundary.

library(sp); library(maps)
win.graph(width=4, height=6)
map('state', region = 'mississippi', col='red')
plot(data.fire, add=T) 
plot(data.ecoregion, add=T)

Any hint is greatly appreciated.


More information about the R-help mailing list