0

I have 2 geospatial datasets - one that identifies hospital and that identifies procedures that took place either in, near or away from such hospitals. Im using ggplot to create a map with points showing all the hospitals and all the procedures done. The point is to visualize how near the procedures are being done in relation to hospitals. Therefore Im trying to produce a circle with a radius of 1Km around every hospital geocoordinate and see how many procedure points lie inside it. The issue is when I try to do this, I cant seem to get the circle to only appear as a border and transparent on the inside (IE I want the radius to only be a 1km circular outline so I can still see the procedure points that fall inside said radius). How can I complete this? My current code is below. Thanks!

ggplot() +  
geom_polygon(data=map_area.df, aes(x=long, y=lat, group=group)) + 
geom_point(data=procedures, aes(x=long, y=lat), size=.01) + scale_color_viridis() +  
geom_point(data=hospitals, aes(x=long, y=lat), size = .02, color="red") + 
geom_circle(aes(x0=longitude, y0=latitude, r = circles), data= hospitals)
 + coord_equal()
aport550
  • 119
  • 1
  • 9

1 Answers1

0

The aesthetic 'fill' is used for this in ggplot but you do not seem to have set it to anything. Can you post an example of the problem? In the following example code I do get transparant circles with only a circular outline:

library(ggplot2)
library(ggforce)

circles <- data.frame(
  x0 = rep(1:3, 3),
  y0 = rep(1:3, each = 3),
  r = seq(0.1, 1, length.out = 9)
)

ggplot() +
  geom_circle(aes(x0 = x0, y0 = y0, r = r), data = circles) +
  coord_fixed()
pieterbons
  • 1,604
  • 1
  • 11
  • 14