Why this script don't even load, and how to debug the issue?

i’m trying to make this process : mla(): Execute supervised classification in satellite images using various algorithms.

//VERSION=3
function setup() {
  return {
    input: ["B8", "B4"], // NIR and RED bands
    output: { bands: 3 }
  };
}

function evaluatePixel(sample) {
  let ndvi = index(sample.B8, sample.B4); // Calculate NDVI
  if (ndvi > 0.3) {
    // Vegetation threshold, adjust as necessary
    return [0, 1, 0]; // Green for high NDVI values
  } else {
    return [1, 1, 1]; // White for low NDVI values
  }
}

function index(NIR, RED) {
  return (NIR - RED) / (NIR + RED);
}

Hi,

It looks like you are trying to output NDVI. To do this, check out this example on the custom scripts repository:

actually i’m trying to make some type of classification and i tried to use gpt and he give me this code -::

mla(): Execute supervised classification in satellite images using various algorithms.

Hi Fares,

This is not a function that you can use in an evalscript, I’m guessing it is a python function but that is all I know. As a word of caution I wouldn’t rely on Chat GPT to give you useable code.

1 Like