A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

New answers tagged

1

Why not making the image collection in one go by mapping over the list of years. THen you can also immediately calculate the RUE as you have both images for a year. var byYear = ee.ImageCollection.fromImages( years.map(function (y) { var start = ee.Date.fromYMD(y, 07, 1); var stop = start.advance(1, 'year'); var sumVeg = smoothed.filterDate(start, ...


0

I found two problems. var tableWithStats = MyImage.reduceRegions({ collection: geometry, reducer: ee.Reducer.mean().combine({ reducer2: ee.Reducer.stdDev(), sharedInputs: true }), scale: 20 }); var std2 = ee.Number(tableWithStats.get("NDVI")).divide(2); var mean1 = ee.Number(tableWithStats.get("NDVI")); You are using reduceRegions, which takes ...


3

I would do something like this: from arcpy.sa import * input_raster = 'path/to/raster' red = Float(Raster(input_raster + r"\Band_3")) nir = Float(Raster(input_raster + r"\Band_4")) ndvi = (nir - red) / (nir + red) ndvi.save("ndvi_result") You could also use GenerateRasterFromRasterFunction_management, but that seems to take much the same processing ...


0

this problem is no longer a problem for my project. My guess is that the polygon I uploaded into GEE has some projection difference than the Sentinel-2 L1C images in the online dataset.


1

I adapted your code for my own raster layers (Landsat 5): import numpy as np import rasterio b4 = rasterio.open('/home/zeito/pyqgis_data/b3_ref.tif') b5 = rasterio.open('/home/zeito/pyqgis_data/b4_ref.tif') red = b4.read() nir = b5.read() np.seterr(divide='ignore', invalid='ignore') # Calculate ndvi ndvi = (nir.astype(float)-red.astype(float))/(nir+red) #...


1

The normalizedDifference() function clamps inputs to be non-negative, i.e., negative values are first set to 0 before evaluating. For most applications using normalizedDifference() is the best practice. The same behavior can be achieved with your band math method by adding .max(0) to the lines that define the red and nir variables. The fact that there are ...


0

There is about a dozen ways to approach this; you could apply clamp, a reducer or simple binary logic: // Get your mean and std var mean = ee.Number(stats.get('nd_mean')) var std = ee.Number(stats.get('nd_stdDev')) // Apply your ranges and turn into binary image indicating 1 between your defined ranges var maskImage = ndvi.updateMask(ndvi.lt(mean.add(std)))....


2

The answer is in your script. When you print your collection size it says there is 0 images in there. Change the filter parameters you apply in your script to ensure there is actually images in your collection


0

I made it work with this code: for (var i in listOfNumbers){ var imageNDVI = ee.Image(listOfImages.get(listOfNumbers[i])); var hotspot=imageNDVI.gt(0.3) .selfMask() .rename('hotspot03'); Map.addLayer(hotspot,{palette: 'FF0000'},i);}


0

I think this will get you there. Make a series of boolean images based on the breakpoints, sum them and then subtract 2 to adjust the values to your final desired range [-1, 1] (you may need to first mask NDVI values greater than 1 or less than -1, if they happen to exist). var zones = function(image) { return ee.ImageCollection.fromImages([ image.gt(...


Top 50 recent answers are included