Hi everyone,
I'm pretty new to R and ggplot2, but I've successfully plotted shapefiles before using the tutorial here (
https://github.com/hadley/ggplot2/wiki/plotting-polygon-shapefiles). However, I ran into an error recently that I couldn't find any info about from Googling around. I'm using shapefile data on police precincts in NYC (available
here). The code I'm running is:
precinctmap <- readOGR("data/nyc_precinctmap","nypp")
precinctmap@data$id <- rownames(precinctmap@data)
precinctmap.points = fortify(precinctmap, region="id")
When I run that 3rd line, I get the following error: "Error: IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4"
Now, it seems like this may be an issue with the shapefile, perhaps? But when I just do plot(precinctmap) it looks totally fine. Does anyone have any ideas?
Thanks!
Max