Edzer,

Thank you so much for helping me. I was able to add shapefile and create
the plot similar to spplot.

However, there seems to be some difference.

The commands i used to add text, north arrow and scale bar seems to be
different in levelplot.

How can I display those ? IN spplot everything would fit into sp.list. IN
levelplot I don't know where should I enter them.

The following are objects/text I added to spplot
l2 = list("SpatialPolygonsRescale", layout.north.arrow(), offset =
c(439000,3368000), scale = 4000)
l3 = list("SpatialPolygonsRescale", layout.scale.bar(), offset =
c(460000,3352000), scale = 5000, fill=c("transparent","black"))
l4 = list("sp.text",c(460000,3351500),"0")
l5 = list("sp.text",c(465000,3351500),"100 m")

Any help is highly appreciated.

Janesh



On Sat, Jan 19, 2013 at 2:25 PM, Edzer Pebesma <
[email protected]> wrote:

> If, by shapefile, you mean a SpatialPolygons object, try:
>
> library(latticeExtra)
> library(sp)
> loadMeuse(river=TRUE)
> levelplot(zinc~x+y, as.data.frame(meuse),
>     panel=function(x,y,subset,...) {
>         panel.levelplot.points(x,y,subset,...)
>         sp.polygons(meuse.riv)
>     },
>     aspect = "iso", scales = list(draw=FALSE), xlab=NULL, ylab = NULL,
>     colorkey = list(space = "bottom"), col.symbol = 0)
>
>
> On 01/19/2013 09:17 PM, Jd Devkota wrote:
> > Hi Edzer
> >
> > Thank you for providing the code to start with.
> >
> > I used that code you gave and slightly modified and got the results
> close.
> > I have posted the links for both level plot and spplot at the bottom of
> the
> > post. The colors on spplot is more smooth than the levelplot but the
> legend
> > on levelplot is better. Another thing what command do I use to add
> > shapefile in level plot ?In spplot I could use sp.list command.
> >
> >
> > The code I used for levelplot is as follows:
> >
> > levelplot(age2100$z~age2100$x+age2100$y, as.data.frame(age2100),
> > panel=panel.levelplot.points,
> >     aspect = "iso", scales = list(draw=FALSE), xlab=NULL, ylab =
> > NULL,cex=1.35,cuts=40,
> >     colorkey = list(space = "bottom"),col.regions = rainbow(100, start =
> > 3/15, end = 1),
> > xlim=c(438000,468900),ylim=c(3347500,3374500))
> >
> > I also tried contourplot in place of levelplot but both of them gave me
> the
> > same plot, no change. I added contour=TRUE, label=TRUE but no change.
> >
> > Please suggest what needs to be done to make the colors smooth like
> spplot.
> >
> > Levelplot has been uploaded on
> > https://www.dropbox.com/s/qng6asyn6uc3x1z/levelplot.png
> >
> > Spplot can be found on
> https://www.dropbox.com/s/0ws3uyiyrreza6n/spplot.png
> >
> > Thanks a lot.
> >
> > Janesh
> >
> >
> >
> > On Sat, Jan 19, 2013 at 12:29 PM, Edzer Pebesma <
> > [email protected]> wrote:
> >
> >>
> >>
> >> On 01/19/2013 07:14 PM, Oscar Perpiñan wrote:
> >>>> Reflecting on that, it would involve a bit of programming, essentially
> >>>> writing an appropriate panel function for lattice::levelplot. I did
> this
> >>>> back then for polygons, found in sp:::panel.polygonsplot, which is 80
> >>>> lines of R code. My guess is that it should be considerable more easy
> >>>> for points. I'd be happy to receive & consider proposals.
> >>>>
> >>>> I think panel.levelplot.points from latticeExtra can be useful:
> >>> http://latticeextra.r-forge.r-project.org/#panel.levelplot.points
> >>>
> >>> Best,
> >>>
> >>> Oscar.
> >>>
> >>
> >> Thanks!
> >>
> >> Sth like
> >>
> >> library(latticeExtra)
> >> library(sp)
> >> loadMeuse()
> >> levelplot(zinc~x+y, as.data.frame(meuse), panel=panel.levelplot.points,
> >>     aspect = "iso", scales = list(draw=FALSE), xlab=NULL, ylab = NULL,
> >>     colorkey = list(space = "bottom"))
> >>
> >>
> >> would get you close, you might want to control xlim and ylim further.
> >>
> >> I'll see how I can integrate this with spplot.
> >>
> >> --
> >> 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.52north.org/geostatistics      [email protected]
> >>
> >> _______________________________________________
> >> R-sig-Geo mailing list
> >> [email protected]
> >> 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.52north.org/geostatistics      [email protected]
>
> _______________________________________________
> R-sig-Geo mailing list
> [email protected]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to