r - Distance raster subset -


i calculate distance raster compute distance cells of raster red border. result displayed on following image: maps discontinuity

nonetheless, want calculate distance cells inside part of border (the rightest part of border). tried ´rasterize´ border, difficult select right part of border.

any ideas?

thanks in advance,

for reproducibility (with available data all):

library(maptools) #to polygon data  data(wrld_simpl) colven <- c("colombia", "venezuela") colven_map <- wrld_simpl[wrld_simpl$name %in% colven, ]  #create raster object library(raster) raster <- raster(colven_map, nrow=100, ncol=100) raster[] <- 1:length(raster) raster_colven <- mask(raster, colven_map)  #calculate distance raster col <- wrld_simpl[wrld_simpl$name == "colombia", ] ven <- wrld_simpl[wrld_simpl$ name == "venezuela", ] ven_l <- as(ven, "spatiallines") ven_p <- as(ven_l, "spatialpoints") distance_raster_colven <- distancefrompoints(raster, ven_p) distance_raster_colven <- mask(distance_raster_colven, colven_map) 

you can manually select piece want:

plot(ven_l) x <- crop(ven_l, drawpoly()) # draw polygon on map 

now

y <- rasterize(x, raster) d <- distance(y) 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -