Skip to content
Prev 20009 / 29559 Next

assigning densities to polygons & chloropleth maps

On Fri, Dec 13, 2013 at 8:06 PM, karengrace84 <kgfisher at alumni.unc.edu> wrote:
So what's the output from that process look like? You want to make a
SpatialPolygonsDataFrame with "NumberOfFish" as one of the variables.
You can work out the number of fish in each polygon from a list of
polygon-ids just by using 'table'. Then match the counts back to the
polygon ids in your SpatialPolygonsDataFrame....

 Once that's done then spplot(df,"NumberOfFish") gets you 99% of the
way there. See the help for spplot for more examples.
If you really want to use ggplot/ggmap then you still need a
SpatialPolygonsDataFrame, but you have to "fortify" it and that adds
another level of complication, and I think ggplot still doesn't handle
polygon features with holes and islands as neatly as the routines in
the sp package.

Barry