0

I do have a shape file which I can plot to a map.

library(maptools)
area <- readShapePoly("Path/file.shp")
area.points = fortify(area)


map <- ggplot() +
     geom_path(data = area.points, 
               aes(x = long, y = lat, group = group),
               color = 'gray', fill = 'white', size = .2)

print(map)

and a list of counties where I know longitude and latitude

counties <- read.csv("./Path/counties.csv)

Is there a way I can find out which county belongs to which Polygon so that I can give the counties on the map different colors?

Peter
  • 355
  • 1
  • 8
  • 23
  • Does your `counties.csv` contain centroids or borders? Or is your shapefile your counties layer? This SO question might help you out. https://stackoverflow.com/questions/19791210/r-ggplot2-merge-with-shapefile-and-csv-data-to-fill-polygons – Anonymous coward May 10 '18 at 17:45
  • It contains the longitude and the latitude of cities in the county. – Peter May 11 '18 at 16:09

0 Answers0