New answers tagged

1

This is a little trick I've been doing: var type1 = ndvi.lt(0) var type2 = ndvi.gte(0).and(ndvi.lt(0.6)) var type3 = ndvi.gte(0.6) var classes = ee.Image([type1, type2, type3]) .selfMask() // Mask 0's .multiply(ee.Image([1, 2, 3])) // Assign values to the classes .reduce(ee.Reducer.firstNonNull()) // Pick first class .unmask(0) // Pixels without ...


1

I usually use the angle band to mask the sides of the scenes, only allowing angles between 31 and 45 degrees. There's often some noise at the beginning and end of each track, so I mask that out too. This might lead to gaps in your composites though, so you might want to skip that in some cases. function maskBorder(image) { var totalSlices = ee.Number(...


3

Assuming your three rasters have the same dimensions, you can use numpy's boolean indexing to accomplish this. First, you need to create three masks, each one corresponding to one of your conditions: con1 = (dcl_array == 1) # raster a is 1 con2 = (dcl_array == 0) # raster a is 0 con3 = (tcd_array == 0) # raster c is 0 Then, you just have to index the ...


2

To get the distribution of NA/non-NA, use table on the values of the raster. Test raster: > r = raster() Fill with 1 to N: > r[] = 1:ncell(r) Set some cells to NA: > r[sample(ncell(r),ncell(r)/5)]=NA To count NA/non-NA, use table: > table(is.na(r[])) FALSE TRUE 51840 12960 To plot this with NA in red, do: plot(r, colNA="red")


0

You may be interested in rioxarray to do this type of operation. It uses rasterio which is an alternative python wrapper for GDAL. import rioxarray import json # load in the geojson file with open("img.geojson") as igj: data = json.load(igj) # if GDAL 3+ crs = data["crs"]["properties"]["name"] # crs = "EPSG:4326" # if GDAL 2 geoms = [feat["geometry"] ...


Top 50 recent answers are included