예제 #1
0
def getEarthExplorerData():
    data = json.loads(request.data)
    lat = float(data['lat'])
    lon = float(data['lon'])
    startDate = data['startDate']
    endDate = data['endDate']

    # today = date.today()
    # yearAgo = today + relativedelta(years = -1)
    # today = today.strftime('%Y-%m-%d')
    # yearAgo = yearAgo.strftime('%Y-%m-%d')

    password = getUSGSPassword()
    api = landsatxplore.api.API('sukhvir', password)
    scenes = api.search(dataset='LANDSAT_ETM_C1',
                        latitude=lat,
                        longitude=lon,
                        start_date=startDate,
                        end_date=endDate,
                        max_cloud_cover=10)
    api.logout()

    result = {
        'scenes': scenes[0:10],
        'totalDataLength': len(scenes),
        # 'startDate': yearAgo,
        # 'endDate': today,
    }
    return result
예제 #2
0
    def descarga():
        api = landsatxplore.api.API("*****@*****.**", "Pokemon22300")

        # Request
        scenes = api.search(dataset='LANDSAT_8_C1',
                            latitude=-38.680782,
                            longitude=-71.2800889,
                            start_date='2019-01-24',
                            end_date='2019-02-01',
                            max_cloud_cover=1)

        #print('{} scenes found.'.format(len(scenes)))

        #print(scenes)

        for scene in scenes:
            #print(scene['displayId'])
            url = 'https://earthexplorer.usgs.gov/browse/full/landsat_8/' + scene[
                'displayId']
            url_ir = 'https://earthexplorer.usgs.gov/browse/full/landsat_8/' + scene[
                'displayId'] + '_TIR'
            #print(url)
            urllib.request.urlretrieve(
                url,
                '/Users/franciscolagos/PycharmProjects/untitled/satelital_img/satelital_org_img.jpg'
            )
            urllib.request.urlretrieve(
                url_ir,
                '/Users/franciscolagos/PycharmProjects/untitled/satelital_img/satelital_org_ir_img.jpg'
            )
        api.logout()
        return True
예제 #3
0
    def DownloadingLandsat(self):
        '''
        # Initialize a new API instance and get an access key
        api = landsatxplore.api.API('Boutaina', 'boutaina123456789')
        type_image=self.dlg.combo_sat.currentText()
        stratDate=self.dlg.dateEditStart.date().toString('yyyy-MM-dd')
        endDate=self.dlg.dateEditEnd.date().toString('yyyy-MM-dd')
        cloudpoucentage=self.dlg.cloudslider.value()
        varLat=36.04305
        varLong=-5.08955

        
        # Request
        scenes = api.search(
            dataset=type_image,
            latitude=varLat,
            longitude=-varLong,
            start_date=stratDate,
            end_date=endDate,
            max_cloud_cover=cloudpoucentage)
        '''
        # Initialize a new API instance and get an access key
        api = landsatxplore.api.API('Boutaina', 'boutaina123456789')

        # Request
        var_latitude = 36.04941
        var_longitude = -5.18683
        var_datedebut = self.dlg.dateEditStart.date().toString('yyyy-MM-dd')
        var_datefin = self.dlg.dateEditEnd.date().toString('yyyy-MM-dd')
        var_cloud = self.dlg.cloudslider.value()
        var_typeSat = self.dlg.combo_sat.currentText()
        print(var_cloud)
        scenes = api.search(dataset=var_typeSat,
                            latitude=var_latitude,
                            longitude=var_longitude,
                            start_date=var_datedebut,
                            end_date=var_datefin,
                            max_cloud_cover=int(var_cloud))
        print('{} Results found/النتائج المتوفرة:'.format(len(scenes)))
        self.dlg.lbl_number_found.setText(
            '{} Results found/النتائج المتوفرة:'.format(len(scenes)))
        for scene in scenes:
            print(scene['acquisitionDate'])
            print('&&&&&&&' + str(scene['cloudCover']) + '&&&&&&&&&')
        i = 0
        self.dlg.tableResult.clear()
        for scene in scenes:
            item = QtWidgets.QTableWidgetItem(scene['acquisitionDate'])
            self.dlg.tableResult.setItem(i, 1, item)
            item1 = QtWidgets.QTableWidgetItem(scene['displayId'])
            self.dlg.tableResult.setItem(i, 0, item1)
            item2 = QtWidgets.QTableWidgetItem(scene['browseUrl'])
            self.dlg.tableResult.setItem(i, 2, item2)
            item3 = QtWidgets.QTableWidgetItem(str(scene['cloudCover']))
            self.dlg.tableResult.setItem(i, 3, item3)
            i = i + 1
        api.logout()
예제 #4
0
def landsat8_search(dataset='LANDSAT_8_C1',
                    bbox=(),
                    start_date='',
                    end_date='',
                    max_cloud_cover=20):
    # Initialize a new API instance and get an access key
    username = '******'
    password = '******'
    api = landsatxplore.api.API(username, password)

    # Request
    # scences is a list, each item in this list is dict
    scenes = api.search(
        dataset=
        dataset,  # [LANDSAT_TM_C1|LANDSAT_ETM_C1|LANDSAT_8_C1]  TM: Landsat4 5  ETM: Landsat7
        bbox=bbox,  # (xmin, ymin, xmax, ymax) format
        start_date=start_date,  # YYYY-MM-DD
        end_date=end_date,  # YYYY-MM-DD, must have this
        max_cloud_cover=
        max_cloud_cover,  # int Max. cloud cover in percent (1-100).
        max_results=40000)  # can not exceed 50000
    api.logout()
    return scenes
# enter user information
username = "" 
password = "" 
dataset = 'LANDSAT_ETM_C1'
outputFolder = './data'


# enter location information
latitude = 0
longitutde = 0
start_date = 'yyyy-mm-dd'
end_date = 'yyyy-mm-dd'
max_cloud_cover = 0


api = landsatxplore.api.API(username, password)

#Scene Requests
scenes = api.search(data,
                    latitude,
                    longitude,
                    start_date,
                    end_date,
                    max_cloud_cover)

for scene in scenes:
    ee.download(scene['entityID'], output_dir = outputFolder)

ee.logout()
api.logout()