Geographic Information Systems Asked by William Speiser on May 30, 2021
I have been trying to make a raster of regression values between reflectance value vs input data at each pixel position in a collection (So, for example the R^2 relationship between daily average precipitation and reflectence value at every pixel position within a given extent). I have tried doing this by filtering MODIS by a list of dates and applying a constant band to each image with a respective input daily data value from CSV data, but I am having trouble extracting a specific CSV value for an individual date and applying it to an individual, respective image. The following code has returned the error "single positional indexer is out-of-bounds" when using the python Google Earth Engine API :
import numpy as np
import pandas as pd
import ee
ee.Initialize()
df=pd.read_csv('.csv')
ROI=ee.Geometry.Polygon([coords])
dates=df['Date'].tolist()
df['DateMillis'] = df['datetime'].astype(np.int64) / int(1e6)
data=df['Data'].tolist()
date = ee.List(dates).map(lambda date: ee.Date(date).millis());
d=ee.List(data)
def maskModisClouds(image):
return image.updateMask(image.select('state_1km').bitwiseAnd(1 << 10).eq(0))
def timeband(image):
return image.addBands(image.metadata('system:time_start'))
def databand(image):
return image.updateMask(ee.Image(((df.loc[df['DateMillis']==image.get('system:time_start'),'Data']).iloc[0])).addBands(image))
col = ee.ImageCollection('MODIS/006/MOD09GQ').filter(ee.Filter.inList("system:time_start", date));
Image = col.filterBounds(ROI);
image=Image.map(maskModisClouds).map(timeband).map(Databand)
Your code is improperly mixing client-side and server-side objects. I can't tell what your databand function is trying to do, but it's not possible, for instance to map a function using "==".
For more information, see: https://developers.google.com/earth-engine/guides/client_server
Answered by Noel Gorelick on May 30, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP