Raster extract by polygon generating NAs

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Raster extract by polygon generating NAs

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
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Raster extract by polygon generating NAs

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 <[hidden email]> 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
> [hidden email]
> 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
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Raster extract by polygon generating NAs

João Carreiras
Thank you Ben, setting na.rm = T did the job.

Best wishes
Joao

On 16 May 2018 at 19:36, Ben Tupper <[hidden email]> wrote:

> 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 <[hidden email]> 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
> [hidden email]
> 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/
>
>
>
>

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