0

I have a TensorFlow model that is trained on an array of reflectance values (red, green, blue, nir) to predict sediment (SSC).

Now, I want to use Landsat 8 image over a region to get the SSC for each pixel in the image.One way that I'm aware of but not sure of implementation is to export each band of image to Google Drive as a GeoTIFF and then read in the file to Colab using the rasterio package.

Here is my code:

L8imgs = (ee.ImageCollection('LANDSAT/LC08/C01/T1_SR').filterDate(startDate, endDate).filterBounds(ROI))
L8imgs = L8imgs.select(['B2', 'B3','B4','B5'], ['blue', 'green', 'red', 'nir'])
L8imgs = L8imgs.map(runModel)

def ann_SSCL8(img):
  I = ee.Image(img)
  ## HOW TO INPUT BAND VALUES AS ARRAY TO tfModel ??
  input=[I.select('blue'),I.select('green'), I.select('nir'), I.select('red')]
  ssc = tfModel.predict(input)    #tfModel stored on drive
0

I was finally able to solve by using image.sampleRectangle() to export the band values as array (like this) to input to the TensorFlow model. But because my region was much bigger than the allowed limit of 262144 pixels, I had to break the region into small manageable chunks (which I did separately in ArcMap and then imported into GEE) followed by mosaicing the output.

Hope it helps others.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.