title: Plot point text labels over polygon w/o overlap
body: <p>Using pointLabel in the maptools package in R will plot text labels for points to avoid overlap of text. </p>
  
  <p>But is there a way to avoid/minimize overlap of text labels with the outline of an underlying polygon created from a shape file? </p>
  
  <p>For example, when plotting location of census blocks, one would like the text labels not to fall on top of nearby census block borders, etc. </p>
  
  <p>The data I am using was acquired from the 2000 Census Blocks Version 12A located at: 
  <a href="http://www.nyc.gov/html/dcp/download/bytes/nycd_12aav.zip" rel="nofollow">http://www.nyc.gov/html/dcp/download/bytes/nycd_12aav.zip</a></p>
  
  <p>and unpacks to the following 5 files: </p>
  
  <pre><code>nycd.dbf
  nycd.prj
  nycd.shp
  nycd.shp.xml
  nycd.shx
  </code></pre>
  
  <p>I intended to label the various blocks from my own text file that contains the vertical list:</p>
  
  <pre><code>Zone 1
  Zone 2 
  Zone 3 
  Zone 4
  etc.
  </code></pre>
  
  <p>I loaded the following libraries:</p>
  
  <pre><code>library(gpclib)
  library(maptools)     
  library(RColorBrewer) 
  library(classInt)
  library(maps)
  </code></pre>
  
  <p>I then tried:</p>
  
  <pre><code>zip=readShapePoly(file.choose())
  </code></pre>
  
  <p>and selected the <code>nycd.shp</code> file above. Then:</p>
  
  <pre><code>plot(zip, col="lightgray", border="black", axes=TRUE, pbg="white")
  </code></pre>
  
  <p>And if it won't cause other conflicts with the labeling, I would prefer to color it:</p>
  
  <pre><code>zip@data$noise &lt;- rnorm(nrow(zip@data))
  colors=brewer.pal(9, "YlOrRd")
  cols[is.na(cols)] &lt;- "#D9D9D9"
  brks=classIntervals(zip$noise, n=9, style="quantile")$brks
  plot(zip, col=colors[findInterval(zip$noise, brks,all.inside=TRUE)], axes=F)
  </code></pre>
  
  <p>How would I label the various regions by Zone 1, Zone 2 etc, without/minimizing the label from extending outside each polygon?  My questions implies I know how to label shape files with text.  I don't know how to label shapes with words, only points with their xy value, or as an expression like alpha/beta with <code>pointLabel</code>. I can figure out some functionality with the <code>maps</code> tool if the text is contained within the original file and can therefore be accessed with a <code>$name</code> extension.  Similar to code I saw from <a href="http://geography.uoregon.edu/GeogR/examples/maps_examples02.htm" rel="nofollow">http://geography.uoregon.edu/GeogR/examples/maps_examples02.htm</a>:</p>
  
  <pre><code># map of large cities
  data(world.cities) # make the world cities location data set from the maps package available
  # match the large cities with those in the database
  m &lt;- match(paste(tolower(as.character(cities$City)),tolower(as.character(cities$Country))),
      paste(tolower(world.cities$name),tolower(world.cities$country.etc)))
  
  # assign the world.cities location information to the large cities
  big.cities &lt;- NULL
  big.cities$name &lt;- cities2$City
  big.cities$long &lt;- world.cities$long[m]
  big.cities$lat &lt;- world.cities$lat[m]
  big.cities
  
  # plot the map
  map("world")
  map.axes()
  points(big.cities$long,big.cities$lat, col="blue")
  text(big.cities$long, big.cities$lat, big.cities$name, col="red", cex=.5
  </code></pre>
  
  <p>But unfortunately this is not a solution for me as there is no <code>$name</code> extension with the labels I would like to use. All I can say is that I didn't post until I went through this site with the internal search, and the last few days online googling.  From what I have seen is that this site and this community helps beginners [relative to the very advanced skills of the people on here] like me. </p>
  
  <p>Thank you in advance.</p>