title: visualizing DMA regions on a map and overlaying results in R
body: <p>I am using the following map: <a href="https://gist.github.com/simzou/6459889#file-nielsentopo-json" rel="nofollow noreferrer">https://gist.github.com/simzou/6459889#file-nielsentopo-json</a>
  to plot the DMA regions.</p>
  <p>I tried following along on this previous stackoverflow[https://stackoverflow.com/questions/35493585/r-import-html-json-map-file-to-use-for-heatmap], however the fortify command doesn't work and I can't figure out why:</p>
  <pre><code>library(sp)
  library(rgdal)
  library(maptools)
  library(rgeos)
  library(ggplot2)
  library(ggalt)
  library(ggthemes)
  library(jsonlite)
  library(purrr)
  library(viridis)
  library(scales)
  
  neil &lt;- readOGR(&quot;~nielsentopo.json&quot;, &quot;nielsen_dma&quot;, stringsAsFactors=FALSE,  verbose=FALSE)
  # there are some techincal problems with the polygon that D3 glosses over
  neil &lt;- SpatialPolygonsDataFrame(gBuffer(neil, byid=TRUE, width=0),
                                    data=neil@data)
  neildf &lt;- as.data.frame(neil)
  neil_map &lt;- fortify(neil, region = 'id')
  
  </code></pre>
  <p>This is the error I receive:</p>
  <pre><code>Too few points in geometry component at or near point -82.061259930000006 26.499350110000002Ring Self-intersection at or near point -89.1404651 29.135150639999999Ring Self-intersection at or near point -78.518767870000005 33.867667130000001SpP is invalid
  Invalid objects found; consider using set_RGEOS_CheckValidity(2L)Error in rgeos::gUnaryUnion(spgeom = SpP, id = IDs) : 
    TopologyException: Input geom 0 is invalid: Ring Self-intersection at or near point -78.518767870000005 33.867667130000001 at -78.518767870000005 33.867667130000001
  </code></pre>
  <p><strong>Can you help?</strong></p>