R: Plotting a shapefile, plots the shapefile many times, not just once

plotpolygonrshapefilespatial-analysis

I am trying to make a map using a particular shapefile as the first layer. The shapefile has multiple attributes and when I plot it, the plot shows the spatial data multiple times for each column in the attribute table. How do I get the plot to only plot once so that I can add more layers to the map?

Here is the code:

UpCarson <- read_sf("UpperCarson.shp")
Gage_L <- read_sf("GageLoc.shp")
extent(UpCarson)
plot(UpCarson, col= NA, border = 'black')
plot(Gage_L, add = TRUE)

The plot looks like this…
Shapefile plotted multiple times, not just once.  I am unable to add additional layers to this plot

Best Answer

You are not telling the function which attribute to plot, you can do this with a bracket plot(UpCarson["tnmid"]) If you don't need the plot symbolized by an attribute you can simply call the geometry plot(st_geometry(UpCarson))

Related Question