TransWikia.com

raster::crop not working as expected

Geographic Information Systems Asked by João Vieira on May 23, 2021

I’m trying to crop a raster stack using a polygon.

structure(chelsa_envs)

class : RasterStack
dimensions : 20880, 43200, 902016000, 19 (nrow, ncol, ncell, nlayers)
resolution : 0.008333333, 0.008333333 (x, y)
extent : -180.0001, 179.9999, -90.00014, 83.99986 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +no_defs
names : CHELSA_bio10_01, CHELSA_bio10_02, CHELSA_bio10_03, CHELSA_bio10_04, CHELSA_bio10_05, CHELSA_bio10_06, CHELSA_bio10_07, CHELSA_bio10_08, CHELSA_bio10_09, CHELSA_bio10_10, CHELSA_bio10_11, CHELSA_bio10_12, CHELSA_bio10_13, CHELSA_bio10_14, CHELSA_bio10_15, …
min values : -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, -32768, …
max values : 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, …

my polygon:

structure(mcp)

class : SpatialPolygons
features : 1
extent : -46.72182, -32.46476, -25.44597, -1.358246 (xmin, xmax, ymin, ymax)
crs : NA

MCP polygon

I’m trying this code:

envs = raster::crop(chelsa_envs, mcp)

but I’m getting "no non-missing arguments to min (and max); returning inf" errors.

Example of one of the resulting rasters (visually different from the polygon):

resulting raster

What am I doing wrong?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP