Giter Site home page Giter Site logo

anitavafaei / biodiversityr Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 13.82 MB

Preserving Biodiversity: An Integrated Approach Using R and the IUCN Red List for Rhinella Granulosa species

License: MIT License

R 100.00%
biodiversity integrated iucn-red-list iucn-red-list-ecosystems preserving r granulosa rhinella

biodiversityr's Introduction

BiodiversityR

Preserving Biodiversity: An Integrated Approach Using R and the IUCN Red List for Rhinella Granulosa species

Screenshot: 'README.md'

Overview

This R code is part of a biodiversity project and aims to assess habitat suitability for different species based on land-use data. The code involves loading spatial data, rasterizing species range shapes, reclassifying land-use, and calculating suitable habitats.

Setup

setwd("C:/Users/Asus/Desktop/biodiversityproject1")
load("redlist_practical.Rdata")
library(maptools)
library(raster)
library(rgdal)
library(sp)
library(Rcpp)

Data Import

lu2005 = raster("landuse_2005.tif")
lu2012 = raster("landuse_2012.tif")
lu_fut = raster("lu_fut.tif")
renelosa = readShapePoly("a3070.shp")

Exploring Data

plot(lu2005)
plot(lu2012)
plot(lu_fut)
plot(renelosa)
plot(renelosa, add = TRUE)

Rasterizing Species Range

renelosa.r = rasterize(renelosa, lu2012, field = 1)
plot(renelosa.r)

Reclassification

reclass = read.delim("reclass_renelosa.txt")
rcl = data.frame(reclass[, c(1, 3)])
suitability2012 = reclassify(lu2012, rcl = rcl)
plot(suitability2012)

Calculating Suitable Habitat

suit_2012_renelosa = suitability2012 * renelosa.r
plot(suit_2012_renelosa)
a = area(suit_2012_renelosa)
zonal(a, suit_2012_renelosa, "sum")

Saving Progress

save.image("redlist_practical.Rdata")

New Species Analysis

renelosa = readShapePoly("a3070.shp")
renelosa.r = rasterize(renelosa, lu2012, field = 1)
reclass = read.delim("reclass_renelosa.txt")
rcl = data.frame(reclass[, 2:3])
suitability2012 = reclassify(lu2012, rcl = rcl)
suit_2012_SPECIESNAME = suitability2012 * SPECIESNAME.r  # replace SPECIESNAME with the actual species name
plot(suit_2012_SPECIESNAME)
a = area(suit_2012_SPECIESNAME)
zonal(a, suit_2012_SPECIESNAME, "sum")

Repeat the above steps for 2005 and future projections.

Future Suitability

suitability_future = reclassify(lu.fut, rcl = rcl)
suit_future_SPECIESNAME = suitability_future * SPECIESNAME.r  # replace SPECIESNAME with the actual species name
plot(suit_future_SPECIESNAME)

Additional Steps

save.image("redlist_practical.Rdata")
  • This code can be used as a guide for analyzing habitat suitability for multiple species in different time periods.

  • Please note that I made a few assumptions, such as the existence of a variable SPECIESNAME.r which needs to be replaced with the actual rasterized species range data. Make sure to replace placeholders like SPECIESNAME with the correct names in your data.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.