Dear All,

I'm building a function for plotting some maps. This function get as
argument a variable and also create some local variables, but then when I
try to read these  variables through layer(sp.points(VARIABLE)), I got the
following error: Object 'VARIABLE' not found...

here the code
#-----------------------------------------------------------------------------
ShowInMap <- function(pDatos)
{
  coordinates(pDatos) <- c("COORDX", "COORDY")
  proj4string(pDatos) <- CRS("+init=epsg:4326")
  pDatos <- spTransform(pDatos,CRS("+init=epsg:23030"))
  browser()
  InterP.IDW <- krige(RS ~ 1, pDatos, gGrid)
  InterP <- InterP.IDW
  InterP[["IDW_pred"]] <- InterP.IDW$var1.pred

  spplot(InterP, c("IDW_pred"), names.attr = c("IDW"), main = "(UTC)",
col.regions = grey(rev(seq(0,0.75,0.05)))) +
  layer(sp.polygons(gEsp, col='blue')) + # /* gEsp is a Global variable and
this line works fine */
  layer(sp.polygons(gCyL, col='cyan')) + # /* gCyL is a Global variable and
this line works fine */
  layer(sp.points(pDatos, col='red', pch = 18)) + #  / * HERE IS THE
PROBLEM with "pDatos", pDatos is working fine in all the other part of code
*/
  layer(sp.text(coordinates(pDatos), round(pDatos$RS,0), adj=0,
col='blue')) # / * HERE IS THE PROBLEM with "pDatos", pDatos is working
fine in all the other part of code */
}
#-----------------------------------------------------------------------------

It seems like if the following code: "layer(sp.points" is pointing to other
environment than local environment of the function... If I change the code
for reading a global variable of course this works fine but I don't like to
do a mess in the code by doing that!

How can I manage that?
What can be the problem?
Is there a way to say "R" that "layer" and "sp.points" have to see this
local environment (like some kind of full-path)?

Thanks in advance for your help

Best regards,

-- 
************************************************************
Federico *Vladimir* Gutierrez Corea   www.vlado.es
PhD Candidate at Technical University of Madrid (UPM)
MERCATOR Research Group
Campus SUR , Paseo de la Arboleda s/n.
E-28031 Madrid (Spain)
E-Mail: fv.gutierrez@upm.es
Ph.:  +34 91 331 1968  (University)
Fax.: +34 91 331 1968 (University)
************************************************************
See *Vladimir* on Linked-In <http://es.linkedin.com/in/fvgutierrez>
See *Vladimir* on GeoI+D Research Center at
UPM<http://www.upm.es/observatorio/vi/index.jsp?pageac=investigador.jsp&idInvestigador=11805>
See *Vladimir* on Google-Scientific
Publications<http://scholar.google.es/scholar?start=0&q=F.+Vladimir+Gutierrez-Corea&hl=en&as_sdt=1>

************************************************************

	[[alternative HTML version deleted]]

