0

I have some regions defined in a dataset that looks like this:

> head(regions_gg)
      lon    lat group
12 -69.75 -19.75     3
13 -69.25 -19.75     3
14 -68.75 -19.75     3
15 -68.25 -19.75     3
16 -67.75 -19.75     3
17 -67.25 -19.75     3

where every point in space has assigned a number, which indicates which region it belongs to. What I want to do is outline these regions and create a border around them. So far, this is the best I could do, but as you can see, it looks hideous.

ggplot(regions_gg,aes(x=lon,y=lat,fill=group,z=group))+theme_bw()+
  geom_raster(interpolate=F)+geom_contour()

geom_contour() is trying to interpolate and adds a lot of unnecessary lines. Is there an easy way to fix this?

EDIT: here's the data regions_gg

  • It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jun 29 '22 at 14:17
  • Maybe [Plot outline around raster cells](https://stackoverflow.com/a/34757965/12993861) helps to answer your question. – stefan Jun 29 '22 at 14:26

0 Answers0