[R] Text in Spatial Polygrams

Jim Burke javajimburke at gmail.com
Wed Aug 26 00:44:33 CEST 2015


I can do this fine for one polygram BUT a for-loop fails.The concept is
multiple lines within each polygon.  I am doing something sub-genius.

ONE POLYGON
   plot(all_pcts_osm_sp[i,], add = FALSE, lwd=.5, border='blue')
   hght <- strheight("Here")
   MyLines <- list(
      bquote( .(all_pcts_osm_sp$PCT[i]) ),
      bquote( .(all_pcts_osm_sp$First_Name[i]) ),
      bquote( .(all_pcts_osm_sp$Last_Name[i]) ),
      bquote( .(all_pcts_osm_sp$Phone) ))
   text( all_pcts_osm_sp[i,]@polygons[[ 1 ]]@labpt[[1]],
         all_pcts_osm_sp[i,]@polygons[[ 1 ]]@labpt[[2]] - (hght * 1.5 *
seq(length(MyLines))),
     do.call(expression, MyLines))

ALL POLYGONS JUST DO NOT WORK.  PUZZLED? Help me please. Also ultimate
target is an OpenStreet ("OSM") backdrop.

   tmp_sp_length <- length(all_pcts_osm_sp)
   i = 1
   for(i in 1:tmp_sp_length) {
      hght <- strheight("Here")
      MyLines <- list(
         bquote( .(all_pcts_osm_sp$PCT[i]) ),
         bquote( .(all_pcts_osm_sp$First_Name[i]) ),
         bquote( .(all_pcts_osm_sp$Last_Name[i]) ),
         bquote( .(all_pcts_osm_sp$Phone) ))
      text( all_pcts_osm_sp[i,]@polygons[[ 1 ]]@labpt[[1]],
         all_pcts_osm_sp[i,]@polygons[[ 1 ]]@labpt[[2]] - (hght * 1.5 *
       seq(length(MyLines))),
         do.call(expression, MyLines))
   }

All your comments, ideas, and thoughts are appreciated.
Thanks
Jim Burke

	[[alternative HTML version deleted]]



More information about the R-help mailing list