[R-sig-Geo] Order raster images in a levelplot
Frede Aakmann Tøgersen
frtog at vestas.com
Tue Oct 21 08:53:51 CEST 2014
Hi
Since no code example was provided we'll have to guess. I suppose it has to do with the way factor() works.
Here is the built-in list of month names in R:
> month.name
[1] "January" "February" "March" "April" "May" "June"
[7] "July" "August" "September" "October" "November" "December"
Now show this as a factor:
> factor(month.name)
[1] January February March April May June July
[8] August September October November December
12 Levels: April August December February January July June March ... September
See how factor() is using lexicographical order for the labels of the factor levels.
Now do this instead:
> factor(month.name, labels = month.name)
[1] May April August January September July June
[8] February December November October March
12 Levels: January February March April May June July August ... December
Now the order of the labels of the levels is the same as that of month.name.
Here is an example:
testdata <- data.frame(x = 1, y = 1, Month = factor(month.name))
### order of panels is that of order(month.name)
xyplot(y ~ x|Month, data = testdata)
testdata <- data.frame(x = 1, y = 1, Month = factor(month.name, labels = month.name))
### order of panels is that of month.name
### January in bottom left and Deccember in top right panel
xyplot(y ~ x|Month, data = testdata)
### use the as.table argument to get January in top left and December in bottom right
xyplot(y ~ x|Month, data = testdata, as.table = TRUE)
Yours sincerely / Med venlig hilsen
Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling
Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
frtog at vestas.com
http://www.vestas.com
Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender.
> -----Original Message-----
> From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-
> project.org] On Behalf Of Oscar Perpiñán Lamigueiro
> Sent: 21. oktober 2014 07:50
> To: Navinder Singh
> Cc: r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] Order raster images in a levelplot
>
> Hi,
>
> > 1. Does someone have any suggestions on how i can order the sequence
> > of images in a levelplot" made using rasterVis. Specifically, i
> > have months i need to arrange in the normal sequence, as the plot
> > currently aligns them in an alphabetical order. Does levelplot
> > works the same way as xyplots in lattice?
>
> levelplot methods defined in rasterVis are based on lattice graphics.
> Most of the arguments provided by lattice::xyplot and
> lattice::levelplot are also available. For this issue you could try
> these arguments: perm.cond, index.cond, as.table. All of them are
> described in the help page of lattice::xyplot.
>
> > 2. Have there been more developments on the zApply function in the
> > raster package? I am trying to make basic statistical summaries for
> > mean monthly (eg. NDVI values) form a multi annual time series. How
> > does one go about using the by" Indexing in this case.
>
> Could you post a reproducible example? I have used zApply for similar
> tasks without problems.
>
> Best,
>
> Oscar.
>
> --
> Oscar Perpiñán Lamigueiro
> Dpto. Ingeniería Eléctrica (ETSIDI-UPM)
> Grupo de Sistemas Fotovoltaicos (IES-UPM)
> URL: http://oscarperpinan.github.io
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list