1

I am currently developing an application which requires LANDSAT NDVI coloured images to be retrieved to local storage. to carry out the task i wrote a script in python using earth engine API (source code attached) in which i am able to retrieve images as attached. please note that the retrieved image does not contain NDVI color information (values).

I have two queries with regard to this.

  1. does the API support such queries which get us the NDVI colored data ?
  2. using map.addlayer function i am able to display the coloured image as per requirements. but here i am facing difficulty in getting the file to local storage.

Program:

import ee
import ee.mapclient 
import datetime
import os
import wget
import sys
from subprocess import call
ee.Initialize()
ulx = 77
uly = 10
lrx = 75
lry = 8
startyear=2012
endyear = 2013
month = 4
for x in range(2012, 2014):
    startyear=x
    endyear=x+1

    regionname = 'alappuzha'
    bands= ['B2', 'B3', 'B4', 'B5']
    output=regionname+'_'+str(endyear)+'_'+str(month)
    os.chdir('/home')
    region=[ulx,lry], [ulx, uly], [lrx, uly], [lrx, lry]  
    strregion=str(list(region))
    def getle8(img): 
        return(img.normalizedDifference(['B5', 'B4']))
        #return(img.expression('float(b("first_b50") - b("first_b40")) / (b("first_b50") + b("first_b40"))'))
    unzippedfilename=output+".le8.tif"
    if(os.path.exists(unzippedfilename)):
        sys.exit("File exists:"+output)
    le7 = ee.ImageCollection("LC8_L1T_TOA").filterDate(datetime.datetime(startyear, 11, 1),
                          datetime.datetime(endyear, 11, 1)).map(getle8);  
    le7a=le7.mean().select([0], ['le1']).multiply(ee.Image(1000)).int16();

    data=le7a
    print(output+' Processing....      Coords:'+strregion)
    path =le7a.getDownloadUrl({
        'name': output,  
        'bands': B2,B3,B4,B5                                                     
        'region': strregion                        
        });
    print("Downloading "+output) 
    wget.download(path)
    zipstatus=call("unzip "+output+".zip",shell=True)    
    if(zipstatus==9):
        sys.exit("File exists:"+output)    
    os.remove(output+".zip")    
    print(output+' Finished!')
  • can you edit your question to say what you've tried, and what issues you have encountered – nmtoken Oct 13 '16 at 11:46

Your Answer

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

Browse other questions tagged or ask your own question.