jin...@ga.gov.au wrote: > Thank you, Edzer. > My second question bas been solved by using: > proj4string(pred.mud.ked) <- CRS("+proj=longlat +datum=WGS84") > > For the first question, I have checked ?levelplot, but found no clue to do > what I intended. Thanks for any further help. > library(sp) data(meuse.grid) gridded(meuse.grid) = ~x+y spplot(meuse.grid["dist"],colorkey = list(at = c(0,.5,1), labels = c("0%", "50%", "100%")),col.regions=cm.colors(2),at=c(0,.5,1))
> Cheers, > Jin > > > -----Original Message----- > From: Edzer Pebesma [mailto:edzer.pebe...@uni-muenster.de] > Sent: Thursday, 23 April 2009 4:08 PM > To: Li Jin > Cc: roger.biv...@nhh.no; r-sig-geo@stat.math.ethz.ch > Subject: Re: [R-sig-Geo] spplot [SEC=UNCLASSIFIED] > > Dear Jin, the > > ..., scales=list(draw=T), ... > > only prints the degree E and degree S on the axis tic marks when it is > convinced the data are in long lat. Use > > proj4string(pred.mud.ked) <- "+proj=longlat" > > maybe with the right datum, to set this for pred.mud.ked; in principle you > could set it early on in your analysis and it should propagate. Be aware that > interpolation in gstat will do something different when it finds out that > data are in degrees, as it can no longer use coordinates "easily" to compute > Euclidian distances. > > To change the colorkey, read the help of function levelplot in package > lattice, in particular argument colorkey. > -- > Edzer > > > jin...@ga.gov.au wrote: > >> Dear Roger and Mike, >> Thank you very much for your kind help. Now I have basically achieved what I >> initially planned. Here is the code used for plotting the attached map. >> >> library(maptools) >> pred.mud.ked<-read.table("mud.ked.csv", sep=",", header=TRUE) >> par (font.axis=2, font.lab=2) >> coordinates(pred.mud.ked) = ~LON+LAT >> gridded(pred.mud.ked)<-TRUE >> jpeg("mud.n.ked100.2.jpeg", width=670, height=670, quality=100) >> trellis.par.set(sp.theme(regions = list(col = >> colorRampPalette(c("lightyellow", "saddlebrown")))) ) >> spplot(pred.mud.ked, c("bt.pred"), scales=list(draw=T), >> xlab=expression("Longitude"^o), ylab=expression("Latitude"^o), >> main = list("Predicted mud distribution in northern Australian EEZ area >> using KED", cex=1, col="black", font=2)) >> dev.off() >> detach(package:maptools) >> >> Now I have two other questions. >> 1. Given that the data range is between 0(%) to 100(%), but the scale bar >> shows a range beyond this data range, how could I make it start from 0(%) to >> 100(%) and also add unit (i.e. %) to the scale bar? >> 2. The text adjacent to axes only show a number without degree symbol and E >> or S, how to add these and make the text adjacent to axes look like >> http://r-spatial.sourceforge.net/gallery/#fig09.R? >> Any help is greatly appreciated. >> Cheers, >> Jin >> >> -----Original Message----- >> From: Roger Bivand [mailto:roger.biv...@nhh.no] >> Sent: Wednesday, 22 April 2009 4:52 PM >> To: Li Jin >> Cc: Michael Sumner; r-sig-geo@stat.math.ethz.ch >> Subject: Re: [R-sig-Geo] spplot [SEC=UNCLASSIFIED] >> >> On Wed, 22 Apr 2009, Michael Sumner wrote: >> >> >> >>> Ouch - sorry about that, I should have checked. >>> >>> I don't know how to set axis labels with spplot I'm afraid. >>> >>> >> Something like: >> >> library(maptools) >> xx <- readShapeSpatial(system.file("shapes/sids.shp", package="maptools")[1], >> IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66")) >> spplot(xx, c("BIR74", "BIR79"), scales=list(draw=TRUE)) >> >> Hope this helps, >> >> Roger >> >> >> >>> Regards, Mike. >>> >>> >>> ==============Original message text=============== >>> On Wed, 22 Apr 2009 11:49:09 +1000 jin...@ga.gov.au wrote: >>> >>> Thank you very much, Mike. That is very helpful. I got the colour I was >>> after. My data are in lat/long, when I tried degAxis I got: >>> >>> >>>> degAxis(1) >>>> >>>> >>> Error in axis(side, at = at, labels = labels, ...) : >>> plot.new has not been called yet >>> >>> >>>> degAxis(2) >>>> >>>> >>> Error in axis(side, at = at, labels = labels, ...) : >>> plot.new has not been called yet >>> It seems degAxis is not working with spplot. Any suggestions? Thanks. >>> Cheers, >>> Jin >>> >>> >>> -----Original Message----- >>> From: Michael Sumner [mailto:mdsum...@utas.edu.au] >>> Sent: Wednesday, 22 April 2009 11:08 >>> To: Li Jin >>> Cc: r-sig-geo@stat.math.ethz.ch >>> Subject: Re: [R-sig-Geo] spplot [SEC=UNCLASSIFIED] >>> >>> This examples shows the use of colorRampPalette(grDevices) to create a >>> color ramp with sp.theme, borrowing from the spplot documentation. See >>> colors()[grep("brown", colors())] >>> to find the browns R already knows about, or generate your own. >>> >>> library(lattice) >>> trellis.par.set(sp.theme(regions = list(col = >>> colorRampPalette(c("sandybrown", "brown4")))) ) >>> >>> >>> data(meuse.grid) >>> gridded(meuse.grid)=~x+y >>> meuse.grid$g = factor(sample(letters[1:5], 3103, >>> replace=TRUE),levels=letters[1:10]) >>> meuse.grid$f = factor(sample(letters[6:10], 3103, >>> replace=TRUE),levels=letters[1:10]) >>> spplot(meuse.grid, c("f","g")) >>> >>> If your data are already in latitude/longitude then just type this to add >>> the graticule and labels: >>> >>> degAxis(1) >>> degAxis(2) >>> >>> If your data use a different projection there's an example here that >>> transforms lines from lat/lon to the grid, but it would be more work to >>> figure out for your case: >>> >>> http://geography.uoregon.edu/GeogR/examples/maps_examples02.htmHTH >>> >>> Regards, Mike. >>> >>> ==============Original message text=============== >>> On Wed, 22 Apr 2009 10:39:21 +1000 jin...@ga.gov.au wrote: >>> >>> Dear all, >>> >>> I am using spplot to generate some maps. The maps produced are beautiful >>> as shown by the attached file, but I was wondering if it is possible to >>> do the following modifications: >>> 1) change the colour to brown, that is a value 0 corresponding to >>> blank/white, 100 to brown, values in between to lighter browns, something >>> like we can get by brown((0:100)/100); this colour is required for mud by >>> my organisation; and >>> 2) add lat and long on the axes/borders. >>> >>> Thanks for your help in advance. >>> >>> Cheers, >>> >>> Jin >>> _______________________________________ >>> Jin Li, PhD >>> Spatial Modeller/Computational Statistician >>> Marine & Coastal Environment >>> Geoscience Australia >>> GPO Box 378, Canberra, ACT 2601, Australia >>> >>> Ph: 61 (02) 6249 9899; email: jin...@ga.gov.au<mailto:jin...@ga.gov.au> >>> _______________________________________ >>> >>> >>> ===========End of original message text=========== >>> >>> >>> >>> If it wasn't backed-up, then it wasn't important. ~ Anon sysadmin >>> >>> Mike Sumner (Phd. Candidate) >>> http://www.antcrc.utas.edu.au/~mdsumner/ http://www.zoo.utas.edu.au/awru/ >>> IASOS/AWRUUniversity of Tasmania >>> Private Bag 80 >>> Hobart Tasmania 7001 >>> AUSTRALIA >>> Email: mdsum...@utas.edu.au >>> Phone: 03 6226 1752 (W) >>> 0408599921 (M) >>> Fax: 03 6226 2745 >>> >>> >>> >>> >>> >>> >>> >>> >>> ===========End of original message text=========== >>> >>> >>> >>> If it wasn't backed-up, then it wasn't important. ~ Anon sysadmin >>> >>> Mike Sumner (Phd. Candidate) >>> http://www.antcrc.utas.edu.au/~mdsumner/ http://www.zoo.utas.edu.au/awru/ >>> IASOS/AWRU >>> University of Tasmania >>> Private Bag 80 >>> Hobart Tasmania 7001 >>> AUSTRALIA >>> Email: mdsum...@utas.edu.au >>> Phone: 03 6226 1752 (W) >>> 0408599921 (M) >>> Fax: 03 6226 2745 >>> >>> _______________________________________________ >>> R-sig-Geo mailing list >>> R-sig-Geo@stat.math.ethz.ch >>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo >>> >>> >>> >> -- >> Roger Bivand >> Economic Geography Section, Department of Economics, Norwegian School of >> Economics and Business Administration, Helleveien 30, N-5045 Bergen, >> Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 >> e-mail: roger.biv...@nhh.no >> >> >> >> ------------------------------------------------------------------------ >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> R-sig-Geo mailing list >> R-sig-Geo@stat.math.ethz.ch >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo >> >> > > -- > Edzer Pebesma > Institute for Geoinformatics (ifgi), University of Münster > Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251 > 8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de/ > http://www.springer.com/978-0-387-78170-9 e.pebe...@wwu.de > > -- Edzer Pebesma Institute for Geoinformatics (ifgi), University of Münster Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251 8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de/ http://www.springer.com/978-0-387-78170-9 e.pebe...@wwu.de _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo