[R-sig-Geo] Question on histograms from Raster and RasterVIS packages
Nuno Sá
nunocesardesa at gmail.com
Wed Nov 19 20:39:28 CET 2014
Hello!
Mr. Pascal, thank you, your suggestion works quite well.
First, I was having error calculating the median using the cellStats
because I was using brackets ("median" as opposed to median) and the error
message mislead me to think it was not implemented (which obviously I
obviously found very strange but moved quickly onwards after Thomas Adams
suggestion).
(This was the error)
Error in .local(x, stat, ...) :
invalid 'stat'. Should be sum, min, max, sd, mean, or 'countNA'
The + operator worked 100% as you've said. So great feedback, thank you soo
much.I am now free to make some more beautiful looking plots hehe
Mr. Hijmanns, I did read the package help but failed to find a mention that
it was not limited to a maximum of 1000000, so my mistake there. It works
perfectly as you've said as well, so thank you so much for the feedback.
As usual, "computers are always right and the user was the error". Good
thing we have these forums and such a quick access to much better users.
Since I have your attention Mr. Hijmanns I ask a quick extra question - in
the cellStats you mention that it will fail "gracefully" for very large
rasters (not my case here since it gracefully succeeded), do you know what
is the limit of cells for that failure?
Once again, thank you all for the help!
Best of luck on everything for all!
Nuno
On 19 November 2014 15:14, Robert J. Hijmans <r.hijmans at gmail.com> wrote:
> Nuno,
>
> > The "hist" function from the raster package uses a maximum of 100 000
> > values for generating the histogram
>
> That is the default, but you do not have to use that. Did you read the
> help file??
>
> ?raster::hist
>
> Shows that you can set the "maxpixels" to any number you want. E.g.
>
> maxpixels=Inf
>
> if you want them all.
>
> With very large raster you may run out of memory. If that happens,
> then you can create the data for a histogram yourself by using the
> function 'freq', perhaps after 'reclassify' (and then probably
> 'barplot').
>
> Robert
>
>
>
>
>
>
> On Tue, Nov 18, 2014 at 9:56 AM, Nuno Sá <nunocesardesa at gmail.com> wrote:
> > Hello!
> >
> > My aim is to add a "Median" or a "Mean" line to an histogram plot in R.
> >
> > The problem is the following:
> >
> > The "hist" function from the raster package uses a maximum of 100 000
> > values for generating the histogram but allows me to edit the plot, so I
> > can easily add a line within the plot using abline.
> >
> > The "histogram" function in rasterVIS uses all my dataset but does not
> > allow editing of the plot area, so I cannot use the abline function to
> add
> > this line (or I do not know how to do it).
> >
> > If you have an alternative or a solution to work around this, I am all
> hears
> >
> > Thank you for any help in advance!
> > Ciao!
> > --
> >
> > Nuno César de Sá
> > +351 91 961 90 37
> >
> > [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo at r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Nuno César de Sá
+351 91 961 90 37
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list