import pandas as pd import geopandas as gps import datetime import ee ee.Authenticate() ee.Initialize() from google.colab import drive drive.mount('/content/drive') """Selccionar Cultivo""" #Maiz_str = '/content/drive/MyDrive/Puntos/Maiz.csv' #df = pd.read_csv(Maiz_str, parse_dates=['Fecha_Siembra', 'Rango_Floor','Rango_Top']) Soja_str = '/content/drive/MyDrive/Puntos/Soja.csv' df = pd.read_csv(Soja_str, parse_dates=['Fecha_Cosecha', 'R3', 'R6']) # En archivo de soja fila 315, columna Fecha_Cosecha modifiqué año 0201 por 2016 df['Start_Date'] = df['R3'] df['End_Date'] = df['R6'] df = df[df['Start_Date'].notna()] df = df[df['End_Date'].notna()] df = df[df['Longitud'].notna()] df = df[df['Latitud'].notna()] new_df = pd.DataFrame([],columns=['id', 'longitude', 'latitude', 'time', 'NDVI', 'Parcela','Codigo_Lote']) for index, row in df.iterrows(): feature = ee.Algorithms.GeometryConstructors.Point([row.Longitud,row.Latitud]) Start_Date = ee.Date(row.Start_Date) End_Date = ee.Date(row.End_Date) dataset = ee.ImageCollection("MODIS/061/MOD13Q1").select('NDVI').filter(ee.Filter.date(Start_Date,End_Date)) NDVIvalues = dataset.getRegion(feature, 250).getInfo() NDVI_df = pd.DataFrame(NDVIvalues) NDVI_df.columns = NDVI_df.iloc[0] NDVI_df = NDVI_df.iloc[1:].reset_index(drop=True) NDVI_df.insert(1, "Parcela", row.Parcela) NDVI_df.insert(1, "Codigo_Lote", row.Codigo_Lote) new_df = new_df.append(NDVI_df) new_df.to_csv('/content/drive/MyDrive/Puntos/NDVI_Puntos.csv',header=True, index=False)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter