0

I have a shapefile of 4 phyla (4 polygons for each class). Each contains multiple species ranges inside it. This means I have data for almost 200 species in these 4 polygon. My data look like this (figure attached below). I get this data from IUCN and clip it for my study region. Link of data is https://www.iucnredlist.org/resources/spatial-data-download

enter image description here

I want to calculate the species richness for each grid cell of (1km by 1km) after rasterizing them in

How do I get the total species in each grid cell like the figure attached below?

enter image description here

If combined richness is not possible, single like reptiles richness can also work for me and so on. I want to do analysis in R.

Update1

I attached the link from where I download the data. Geometry of Polygons ar Multipolygons. These 4 polygons contain data of 200 species (81 for reptiles, 104 for mammals and remaining 15 for other 2 phylum. So 81 column for reptiles species and so on (attribute table of only one phylum (reptile) is attached below to understand data type).

enter image description here enter image description here

I am new on R and I don't know how to even load the polygon file in R.

4
  • Maybe something like this can work?: stackoverflow.com/questions/37682415/…
    – BERA
    Nov 15, 2021 at 6:41
  • How do you get 200 species from 4 polygons? Does each polygon have 200 columns giving species info? Or is that four layers of polygons in QGIS? How many features (actual polygonal regions) are there and how do you get the species info from that? Do you know how to load spatial data like this into R? Can you do that and show us some summaries from R? Please edit your question to clarify all this and that will help us help you.
    – Spacedman
    Nov 15, 2021 at 7:37
  • I have edit the question under Update section. Please have look on it _Spacedman
    – user_3264
    Nov 15, 2021 at 8:21
  • 1
    Until this gets answered, you should probably up your skills with R and with Geospatial i R - look at the "Geocomputation in R" book (free, online) and work through the basics. geocompr.robinlovelace.net/index.html
    – Spacedman
    Nov 15, 2021 at 12:15

1 Answer 1

1
        library(raster)
        library(sf)

        poly <- st_read("directory.shp")

# Creating a raster 
##write the rows column of polygonn and xmn, xmx, ymn, ymx according to your country data

             r <- raster(nrows=, ncols=, xmn=, xmx=, ymn= , ymx=, 
            crs = "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0", 
            resolution = 0.008333333, vals=NULL)

          a <- rasterize(poly, 
               r,
               field = "binomial",
               fun = function (x, ...) length(unique(na.omit(x))))

            plot(a)

Hope so its work for you.

1
  • 1
    This is for single polygon. if I wants to combine multiple polygons to find the accumulative richness of species. How can I combine the polygons in r.
    – user_3264
    Nov 15, 2021 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.