diego-ellis-soto commited on
Commit
638104e
·
1 Parent(s): f5e711f

Defined terra as crop

Browse files
Files changed (2) hide show
  1. R/setup.R +1 -1
  2. app.R +4 -4
R/setup.R CHANGED
@@ -35,7 +35,7 @@ if (!"name" %in% names(osm_greenspace)) {
35
  }
36
 
37
  # -- NDVI Raster
38
- ndvi <- rast("data/SF_EastBay_NDVI_Sentinel_10.tif")
39
 
40
  # -- GBIF data
41
  # Load what is basically inter_gbif !!!!!
 
35
  }
36
 
37
  # -- NDVI Raster
38
+ ndvi <- terra::rast("data/SF_EastBay_NDVI_Sentinel_10.tif")
39
 
40
  # -- GBIF data
41
  # Load what is basically inter_gbif !!!!!
app.R CHANGED
@@ -673,8 +673,8 @@ server <- function(input, output, session) {
673
 
674
  iso_union <- st_union(iso_data)
675
  iso_union_vect <- vect(iso_union)
676
- ndvi_crop <- crop(ndvi, iso_union_vect)
677
- ndvi_mask <- mask(ndvi_crop, iso_union_vect)
678
  ndvi_vals <- values(ndvi_mask)
679
  ndvi_vals <- ndvi_vals[!is.na(ndvi_vals)]
680
 
@@ -777,8 +777,8 @@ server <- function(input, output, session) {
777
 
778
  # NDVI Calculation
779
  poly_vect <- vect(poly_i)
780
- ndvi_crop <- crop(ndvi, poly_vect)
781
- ndvi_mask <- mask(ndvi_crop, poly_vect)
782
  ndvi_vals <- values(ndvi_mask)
783
  ndvi_vals <- ndvi_vals[!is.na(ndvi_vals)]
784
  mean_ndvi <- ifelse(length(ndvi_vals) > 0, round(mean(ndvi_vals, na.rm=TRUE), 3), NA)
 
673
 
674
  iso_union <- st_union(iso_data)
675
  iso_union_vect <- vect(iso_union)
676
+ ndvi_crop <- terra::crop(ndvi, iso_union_vect)
677
+ ndvi_mask <- terra::mask(ndvi_crop, iso_union_vect)
678
  ndvi_vals <- values(ndvi_mask)
679
  ndvi_vals <- ndvi_vals[!is.na(ndvi_vals)]
680
 
 
777
 
778
  # NDVI Calculation
779
  poly_vect <- vect(poly_i)
780
+ ndvi_crop <- terra::crop(ndvi, poly_vect)
781
+ ndvi_mask <- terra::mask(ndvi_crop, poly_vect)
782
  ndvi_vals <- values(ndvi_mask)
783
  ndvi_vals <- ndvi_vals[!is.na(ndvi_vals)]
784
  mean_ndvi <- ifelse(length(ndvi_vals) > 0, round(mean(ndvi_vals, na.rm=TRUE), 3), NA)