Maria--

I believe that your NAs from the extract are because those polygons do not
cover at least 1 center point of a pixel in your bioclim rasters.  One
solution is to use small=TRUE in your call to extract: see ?extract for
more information.  Another would be to pull the bioclim data with pixels
smaller than 2.5minutes (and still use small=TRUE).

Your other issues require more information about the scales of your
bioclime data and of the entire species ranges, the reason the species
ranges are multi-part polygons (e.g., many mountain tops, or a broad range
where they separately digitized water as holes and islands as small
included polygons), and most importantly, what question you are trying to
ask.

If you want an 'average' for each bioclim variable for each species, you
should make sure your extract specifies fun-'mean':
   v <- extract(bios,spX,small=TRUE,fun='mean')
and then average across your polygons weighted by polygon area.  If a
substantial proportion of your polygons are smaller than ~50 pixels, you
may need to use weights=TRUE within the extract() call, especially if your
bioclim values vary greatly between adjacent pixels.  I don't know that
will work in combination with using extract() on the rasterBrick of
bioclim, as the result would be a 3 or 4 dimensional array instead of a
matrix.  If that happens, then you need to make your SpatialPolygons object
have a single Polygon in its polygons slot.  My copy of ASDAR (Bivand et
al.'s Applied Spatial Data Analysis with R) is AWOL, but I believe it shows
how to do this.

That said, in my work, such average values would be meaningless for the
questions I ask: I need to compute the ranges of each bioclim attribute for
a given species, and an envelope of the combinations of bioclim attribute
values occurring within the geographic range.  [I'm using bioclim
attributed generated for the US at 800m pixels based on PRISM normals, and
rangemaps of vertebrates.]

I hope that this points you in a useful direction,
Tom



On Fri, Sep 13, 2013 at 12:38 PM, Maria Fernanda Bonetti <
fernanda_bonetti@hotmail.com> wrote:

> Hi all
>
>
>
>
> I need to extract climatic variables of many shapefiles. I managed to do
> it, but doing one at a time (I have to do this for 3000 species).
> Well, I did the following:
> first I downloaded the rasters of BIOCLIM> bios <-getData ("Worldclim" var
> = "bio", res = 2.5, T = download)
> Ok, then I went with shapes (2 species did just to test).> teste_sp1
> <-readShapePoly ("sp1", IDVAR = NULL, proj4string = CRS (as.character
> (NA)), verbose = FALSE, repair = FALSE, FALSE = force_ring, delete_null_obj
> = FALSE, retrieve_ABS_null = FALSE)
> Finally, I used a function to extract the variables of shapes> v <-
> extract (bios, sp1)
>
> THE PROBLEM:The sp1 is a multi part polygon (23 features). I could make
> the average of these 23 lines and everything would be ok right? The problem
> is that some lines appears NA, and I have no idea why, and I can not just
> ignore that.
> Do I need to join these parts into a single polygon? I tried this with
> "unionSpatialPolygons" but another error appears: Error in
> unionSpatialPolygons (sp1, IDS, threshold = NULL,: input lengths differ
> Can anyone help me?
>
> Att,
> Maria Fernanda BonettiDoutoranda do Programa de Pós Graduação em Ecologia
> e Conservação - UFPRMestre em Ecologia e ConservaçãoPesquisadora do
> Instituto de Pesquisas Cananéia - IPeC
>
>
>
>
>         [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
>


-- 
-------------------------------------------
Tom Philippi, Ph.D.
Quantitative Ecologist & Data Therapist
Inventory and Monitoring Program
National Park Service
Tom_Philippi@nps.gov
http://science.nature.nps.gov/im/monitor

	[[alternative HTML version deleted]]

