0

I have several Spatial Polygon Data Frames I am adding successively to a plot in R 4.0.2. The polygons represent US States, National Forests, National Parks, and wildfire perimeters. While it probably doesn't make sense to provide links to all the data for a fully reproduced working example, the following code is a simplified version of the plot I made:

# equal area projection
proj_coords <- "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0"

# load libraries
library(rgdal)
library(rgeos)

# Make a bbox of the total extent
e <- as(raster::extent(-1400000,-850000,2300000,2750000), "SpatialPolygons")
proj4string(e) <- proj_coords

# Make a smaller box to add to the plot for Stack overflow example
e2 <- as(raster::extent(-1300000,-900000,2400000,2650000), "SpatialPolygons")
proj4string(e2) <- proj_coords

# Plot
lt.green <- adjustcolor("lightgreen", alpha.f = 0.5)
plot(e,axes=T,xlim=c(-1150000,-1100000),ylim=c(2350000,2700000),lwd=2,border="grey",xlab="m",ylab="m")
plot(e2,add=T,col=lt.green,border="grey")

My question:

In my real plot, e2 are National Forest boundaries, some of which extend beyond the extent of the plot axes. When I try to add them to the plot with

lt.green <- adjustcolor("lightgreen", alpha.f = 0.5) 
plot(e2,add=T,col=lt.green,border="grey")

all of the National Forest boundaries plot, but some of them are not filled with color. This is true both when I print the graphic in the console and when I try to export it as a png.

Below is the actual png. The polygons with empty, thin gray borders are the National Forests that are failing to fill with color, while the green ones are correctly filled.

enter image description here

3
  • GIS SE site has policy of focused questions, so please ask only one question per question. – TomazicM Jan 26 at 16:52
  • Should I delete it and repost it? – gcgaines Jan 26 at 18:40
  • No, just edit it and focus on one question only. – TomazicM Jan 26 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.