R: Changing values from raster at certain coordinates

Marie Stessens

I run species distribution models in R and want to create variable rasters for the mainland of Africa, without the islands. I can only find shapefiles of Africa with its islands, not from the mainland only.

1) Where can I possibly download a shapefile of the mainland only?

2) If there is no shapefile, I would like to manually delete the islands from my raster. Is there a way to do this, f.e. setting parts of the rasters between certain coordinates to NA?

Robert Hijmans

Yes, but you need to provide a minimal, self-contained, reproducible example. The easiest approach might be to use Africa polygons africa and do

library(raster)
afr <- aggregate(africa)
v <- disaggregate(afr)
a <- area(v)
afnois <- v[which.max(a), ]

And then used that in mask to remove the islands from the rasters

You can also create polygons with raster::drawPoly and use these for masking.

Este artigo é coletado da Internet.

Se houver alguma infração, entre em [email protected] Delete.

editar em
0

deixe-me dizer algumas palavras

0comentários
loginDepois de participar da revisão

Artigos relacionados

Floor values in raster stack cell to certain quantile of cell values r

Converting coordinates, radius and site type data from .csv to raster in R

Changing long, lat values of Polygon coordinates in python

Extract values from raster and append to existing dataframe

Extracting values of a certain date from JSON in R Dataframe

Listing cities from coordinates in R

How to Replace Raster Values Less than 0 to NA in R code

Changing values in a matrix depending on whether they are above of below a certain threshold value

Can I extract certain dissimilarity values from a bray curtis matrix in R?

changing values in vector given a location and condition with R

Extract each RGB layers from raster and paste into matrix in R

Changing nested URL Values from API

ansible obtain values from changing key

How to repeat values until certain year in R

How to get a value of function corresponding to certain coordinates without actually replacing the values in code?

Extracting pixels values and coordinates in neighborhood of given buffer in R

Saving coordinates of specific pixel values from .mat file

Fipy Get values from a mesh region and not by point coordinates

OpenGL: changing texture coordinates on the fly

Get coordinates from a drawing object from an R leaflet map

Convert raster into matrix with R

Replacing values in column with values from different column if they are a certain value

Why does Rect from Canvas move up and down when changing it's y coordinates?

How to add the extracted values from raster stack to the data.frame of the Spatial object using terra package?

Transform a Multipolygon SF object in R from XY coordinates to lat/lon

R: extracting certain rows from dataframe

A nested array is changing to a string of values going from JavaScript to Rails

HashMap changing its values after saving and reading it back from a file

R - How to exclude cases based on the number of NA values in certain variables