Re: [R-sig-Geo] Will upcoming ggplot2::calc() clash with raster::calc()?

2018-05-16 Thread Barry Rowlingson
It seems the options are:

1. ggplot2 and raster use calc - scripts will have to use raster::calc or
ggplot2::calc to be ambiguous.

 This is the painful solution. Scripts will break. Users will have to type
raster::calc or ggplot2::calc depending on the order they do
library(raster);library(ggplot2). Both packages are often used together.

2. `calc` becomes a "generic" and despatches to the right specific function
when called on a raster or whatever ggplot2::calc needs.

 This either requires "ggplot2" to have "raster" as a dependency or for the
generic to be moved to a package that each of these will depend on. An S3
or S4 generic? Will it even work? Nobody wants to manage the dependency.

3. Use a different name in `ggplot2`, for example, `val`, which has the
same sense - compare:

   geom_histogram(aes(y = *calc*(count)))
   geom_histogram(aes(y = *val*(count)))

4. ggplot2 does something else - maybe the aesthetic could be specified as
a formula?

  geom_histogram(aes(y = ~count))

 but that would require a chunk of ggplot2 rewriting

Barry





On Tue, May 15, 2018 at 6:58 PM, Edzer Pebesma <
edzer.pebe...@uni-muenster.de> wrote:

> This was asked on twitter:
> https://twitter.com/hadleywickham/status/996430251499536385 , by Hadley
> Wickham:
>
> "Can any raster user comment on if the new ggplot2::calc() function is
> going to cause significant pain because it clashes with raster::calc()?"
>
> I'll report answers back to twitter, or directly to Hadley if it doesn't
> fit in 280 chars.
> --
> Edzer Pebesma
> Institute for Geoinformatics
> Heisenbergstrasse 2, 48151 Muenster, Germany
> Phone: +49 251 8333081
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Will upcoming ggplot2::calc() clash with raster::calc()?

2018-05-16 Thread Hadley Wickham
We are tracking at https://github.com/tidyverse/ggplot2/issues/2614 —
and have come up with a name that I prefer to calc(): stat().

Hadley

On Wed, May 16, 2018 at 9:42 AM, Barry Rowlingson
 wrote:
> It seems the options are:
>
> 1. ggplot2 and raster use calc - scripts will have to use raster::calc or
> ggplot2::calc to be ambiguous.
>
>  This is the painful solution. Scripts will break. Users will have to type
> raster::calc or ggplot2::calc depending on the order they do
> library(raster);library(ggplot2). Both packages are often used together.
>
> 2. `calc` becomes a "generic" and despatches to the right specific function
> when called on a raster or whatever ggplot2::calc needs.
>
>  This either requires "ggplot2" to have "raster" as a dependency or for the
> generic to be moved to a package that each of these will depend on. An S3
> or S4 generic? Will it even work? Nobody wants to manage the dependency.
>
> 3. Use a different name in `ggplot2`, for example, `val`, which has the
> same sense - compare:
>
>geom_histogram(aes(y = *calc*(count)))
>geom_histogram(aes(y = *val*(count)))
>
> 4. ggplot2 does something else - maybe the aesthetic could be specified as
> a formula?
>
>   geom_histogram(aes(y = ~count))
>
>  but that would require a chunk of ggplot2 rewriting
>
> Barry
>
>
>
>
>
> On Tue, May 15, 2018 at 6:58 PM, Edzer Pebesma <
> edzer.pebe...@uni-muenster.de> wrote:
>
>> This was asked on twitter:
>> https://twitter.com/hadleywickham/status/996430251499536385 , by Hadley
>> Wickham:
>>
>> "Can any raster user comment on if the new ggplot2::calc() function is
>> going to cause significant pain because it clashes with raster::calc()?"
>>
>> I'll report answers back to twitter, or directly to Hadley if it doesn't
>> fit in 280 chars.
>> --
>> Edzer Pebesma
>> Institute for Geoinformatics
>> Heisenbergstrasse 2, 48151 Muenster, Germany
>> Phone: +49 251 8333081
>>
>> ___
>> R-sig-Geo mailing list
>> R-sig-Geo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



-- 
http://hadley.nz

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


[R-sig-Geo] Raster extract by polygon generating NAs

2018-05-16 Thread João Carreiras
Greetings!

I'm using the extract command (raster package) with a raster layer (x)
and a spatial polygons dataframe (y). I'm using it to extract the sum
of raster values by each spatial polygon. However, I'm getting NAs as
a result for some polygon IDs, which I know isn't true because that
doesn't happen in ArcGIS.

Does anyone experienced the same issue?

Thanks!
Joao

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Raster extract by polygon generating NAs

2018-05-16 Thread Ben Tupper
Hi,

It's hard to know without any reproducible code, but you will want to pay close 
attention to the value of the na.rm argument to 
raster::extract(Raster,SpatialPolygons)  

See ?extract for all the details.

Cheers,
Ben

> On May 16, 2018, at 2:27 PM, João Carreiras  wrote:
> 
> Greetings!
> 
> I'm using the extract command (raster package) with a raster layer (x)
> and a spatial polygons dataframe (y). I'm using it to extract the sum
> of raster values by each spatial polygon. However, I'm getting NAs as
> a result for some polygon IDs, which I know isn't true because that
> doesn't happen in ArcGIS.
> 
> Does anyone experienced the same issue?
> 
> Thanks!
> Joao
> 
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

Tick Forecasting: https://eco.bigelow.org/





[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo