On Nov 20, 2012, at 3:15 AM, riodementa wrote: > I want to represent a Raster map of class "asc", and in the same window a > list of points with the funcion points(x,y).. > > I considered two options: > 1. With image.plot(map) and then use points(x,y). > It works, and the points are in the correct place, but when I maximize > the plot the points are moved to a wrong place. > > My second option was using image.asc(map) and then use points(x,y) and all > works! I can minimize, maximize.... > But with this option, for me is not possible to show a legend strip in the > right side of the window. > > Any suggestion? > > Yo can understand my problem using this: > CASE 1 > file1 <- paste(system.file(package = > "adehabitat"),"ascfiles/elevation.asc", sep = "/") > map<-import.asc(file1) > image.plot(map,col=terrain.colors(100)) > points(700440,3160561) > > CASE2 > image.asc(map,col=terrain.colors(100)) > points(700440,3160561)
You will notice that the image function in base r graphics uses a [0,1] x [0,1] coordinate system. x <- y <- seq(-4*pi, 4*pi, len=27) r <- sqrt(outer(x^2, y^2, "+")) image(z = z <- cos(r^2)*exp(-r/6), col=gray((0:32)/32)) # NOT the same plotted range as input. points(0,0) # appears in lower-most, left-most cell points(0.5,0.5, col= "red") # appears in center If the image.asc function ( in whatever unnamed package it resides in) uses the same transformation strategy, then you will need to transform your point values, using the values of the x and y ranges of your input data. -- David Winsemius, MD Alameda, CA, USA ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.