1

I am using Python to get data from GEE.

I would like to get daily data of Land Surface Temperature (LST) from GEE for a specific region.

This is what I am doing.

# Initial date of interest 
i_date = '2016-01-01'
# Final date of interest 
f_date = '2017-01-01'
lst = ee.ImageCollection('MODIS/006/MOD11A1')
lst = lst.select('LST_Day_1km').filterDate(i_date, f_date)
lstGeo = lst.filterBounds(geometry=myGeo)

I would like to save the data of the LST as a datraframe with columns Lat, Lon, LstDay, Date. Is it possible?

This is the result that I get.

lstGeo.getInfo()
{'bands': [],
 'features': [{'bands': [{'crs': 'SR-ORG:6974',
     'crs_transform': [926.625433056,
      0,
      -20015109.354,
      0,
      -926.625433055,
      10007554.677],
     'data_type': {'max': 65535,
      'min': 0,
      'precision': 'int',
      'type': 'PixelType'},
     'dimensions': [43200, 21600],
     'id': 'LST_Day_1km'}],
   'id': 'MODIS/006/MOD11A1/2016_01_01',
   'properties': {'system:asset_size': 754059586,
    'system:footprint': {'coordinates': [[-180, -90],
      [180, -90],
      [180, 90],
      [-180, 90],
      [-180, -90]],
     'type': 'LinearRing'},
    'system:index': '2016_01_01',
    'system:time_end': 1451692800000,
    'system:time_start': 1451606400000},
   'type': 'Image',
   'version': 1508833200614994},
  {'bands': [{'crs': 'SR-ORG:6974',
     'crs_transform': [926.625433056,
      0,
      -20015109.354,
      0,
      -926.625433055,
      10007554.677],
     'data_type': {'max': 65535,
      'min': 0,
      'precision': 'int',
      'type': 'PixelType'},
     'dimensions': [43200, 21600],
     'id': 'LST_Day_1km'}],
   'id': 'MODIS/006/MOD11A1/2016_01_02',
   'properties': {'system:asset_size': 784476183,
    'system:footprint': {'coordinates': [[-180, -90],
      [180, -90],
      [180, 90],
      [-180, 90],
      [-180, -90]],
     'type': 'LinearRing'},
    'system:index': '2016_01_02',
    'system:time_end': 1451779200000,
    'system:time_start': 1451692800000},
   'type': 'Image',
   'version': 1508824100752325}],
 'id': 'MODIS/006/MOD11A1',
 'properties': {'date_range': [952214400000, 1621641600000],
  'description': '<p>The MOD11A1 V6 product provides daily land surface temperature\n(LST) and emissivity values in a 1200 x 1200 kilometer grid. The\ntemperature value is derived from the MOD11_L2 swath product. Above\n30 degrees latitude, some pixels may have multiple observations\nwhere the criteria for clear-sky are met. When this occurs, the\npixel value is the average of all qualifying observations. Provided\nalong with both the day-time and night-time surface temperature\nbands and their quality indicator layers are MODIS bands 31 and\n32 and six observation layers.</p><p>Documentation:</p><ul><li><p><a href="https://lpdaac.usgs.gov/documents/118/MOD11_User_Guide_V6.pdf">User&#39;s Guide</a></p></li><li><p><a href="https://lpdaac.usgs.gov/documents/119/MOD11_ATBD.pdf">Algorithm Theoretical Basis Document (ATBD)</a></p></li><li><p><a href="https://ladsweb.modaps.eosdis.nasa.gov/filespec/MODIS/6/MOD11A1">General Documentation</a></p></li></ul><p><b>Resolution</b><br>1000 meters\n</p><p><b>Cadence</b><br>\n  1 day\n</p><p><b>Bands</b><table class="eecat"><tr><th scope="col">Name</th><th scope="col">Description</th></tr><tr><td>LST_Day_1km</td><td><p>Daytime Land Surface Temperature</p></td></tr><tr><td>QC_Day</td><td><p>Daytime LST Quality Indicators</p></td></tr><tr><td colspan=100>\n      Bitmask for QC_Day\n<ul><li>\n          Bits 0-1: Mandatory QA flags\n<ul><li>0: LST produced, good quality, not necessary to examine more detailed QA</li><li>1: LST produced, other quality, recommend examination of more detailed QA</li><li>2: LST not produced due to cloud effects</li><li>3: LST not produced primarily due to reasons other than cloud</li></ul></li><li>\n          Bits 2-3: Data quality flag\n<ul><li>0: Good data quality</li><li>1: Other quality data</li><li>2: TBD</li><li>3: TBD</li></ul></li><li>\n          Bits 4-5: Emissivity error flag\n<ul><li>0: Average emissivity error ≤ 0.01</li><li>1: Average emissivity error ≤ 0.02</li><li>2: Average emissivity error ≤ 0.04</li><li>3: Average emissivity error &gt; 0.04</li></ul></li><li>\n          Bits 6-7: LST error flag\n<ul><li>0: Average LST error ≤ 1K</li><li>1: Average LST error ≤ 2K</li><li>2: Average LST error ≤ 3K</li><li>3: Average LST error &gt; 3K</li></ul></li></ul></td></tr><tr><td>Day_view_time</td><td><p>Local time of day observation</p></td></tr><tr><td>Day_view_angle</td><td><p>View zenith angle of day observation</p></td></tr><tr><td>LST_Night_1km</td><td><p>Nighttime Land Surface Temperature</p></td></tr><tr><td>QC_Night</td><td><p>Nighttime LST Quality indicators</p></td></tr><tr><td colspan=100>\n      Bitmask for QC_Night\n<ul><li>\n          Bits 0-1: Mandatory QA flags\n<ul><li>0: LST produced, good quality, not necessary to examine more detailed QA</li><li>1: LST produced, other quality, recommend examination of more detailed QA</li><li>2: LST not produced due to cloud effects</li><li>3: LST not produced primarily due to reasons other than cloud</li></ul></li><li>\n          Bits 2-3: Data quality flag\n<ul><li>0: Good data quality</li><li>1: Other quality data</li><li>2: TBD</li><li>3: TBD</li></ul></li><li>\n          Bits 4-5: Emissivity error flag\n<ul><li>0: Average emissivity error ≤ 0.01</li><li>1: Average emissivity error ≤ 0.02</li><li>2: Average emissivity error ≤ 0.04</li><li>3: Average emissivity error &gt; 0.04</li></ul></li><li>\n          Bits 6-7: LST error flag\n<ul><li>0: Average LST error ≤ 1K</li><li>1: Average LST error ≤ 2K</li><li>2: Average LST error ≤ 3K</li><li>3: Average LST error &gt; 3K</li></ul></li></ul></td></tr><tr><td>Night_view_time</td><td><p>Local time of night observation</p></td></tr><tr><td>Night_view_angle</td><td><p>View zenith angle of night observation</p></td></tr><tr><td>Emis_31</td><td><p>Band 31 emissivity</p></td></tr><tr><td>Emis_32</td><td><p>Band 32 emissivity</p></td></tr><tr><td>Clear_day_cov</td><td><p>Day clear-sky coverage</p></td></tr><tr><td>Clear_night_cov</td><td><p>Night clear-sky coverage</p></td></tr></table><p><b>Terms of Use</b><br><p>MODIS data and products acquired through the LP DAAC have no restrictions on subsequent use, sale, or redistribution.</p><br><b>Dataset\'s DOI(s)</b><ul><li><p><a href="https://doi.org/10.5067/MODIS/MOD11A1.006">https://doi.org/10.5067/MODIS/MOD11A1.006</a></li></ul><p><b>Suggested citation(s)</b><ul><li><p>Please visit <a href="https://lpdaac.usgs.gov/citing_our_data">LP DAAC &#39;Citing Our Data&#39; page</a> for information on citing LP DAAC datasets.</p></li></ul><style>\n  table.eecat {\n  border: 1px solid black;\n  border-collapse: collapse;\n  font-size: 13px;\n  }\n  table.eecat td, tr, th {\n  text-align: left; vertical-align: top;\n  border: 1px solid gray; padding: 3px;\n  }\n  td.nobreak { white-space: nowrap; }\n</style>',
  'period': 1,
  'period_mapping': [952214400000, 1621641600000],
  'product_tags': ['surface_temperature', 'emissivity', 'lst'],
  'provider': 'NASA LP DAAC at the USGS EROS Center',
  'provider_url': 'https://doi.org/10.5067/MODIS/MOD11A1.006',
  'sample': 'https://mw1.google.com/ges/dd/images/MODIS_006_MOD11A1_sample.png',
  'source_tags': ['modis',
   'mod11a1',
   'daily',
   'global',
   'terra',
   'usgs',
   'nasa'],
  'system:is_global': 1,
  'system:visualization_0_bands': 'LST_Day_1km',
  'system:visualization_0_bias': '-1400.0',
  'system:visualization_0_gain': '0.1',
  'system:visualization_0_max': '16500.0',
  'system:visualization_0_min': '13000.0',
  'system:visualization_0_name': 'Land Surface Temperature',
  'system:visualization_0_palette': '040274,040281,0502a3,0502b8,0502ce,0502e6,0602ff,235cb1,307ef3,269db1,30c8e2,32d3ef,3be285,3ff38f,86e26f,3ae237,b5e22e,d6e21f,fff705,ffd611,ffb613,ff8b13,ff6e08,ff500d,ff0000,de0101,c21301,a71001,911003',
  'tags': ['modis',
   'mod11a1',
   'daily',
   'global',
   'terra',
   'usgs',
   'nasa',
   'surface_temperature',
   'emissivity',
   'lst'],
  'thumb': 'https://mw1.google.com/ges/dd/images/MODIS_006_MOD11A1_thumb.png',
  'title': 'MOD11A1.006 Terra Land Surface Temperature and Emissivity Daily Global 1km',
  'type_name': 'ImageCollection',
  'visualization_0_bands': 'LST_Day_1km',
  'visualization_0_bias': '-1400.0',
  'visualization_0_gain': '0.1',
  'visualization_0_max': '16500.0',
  'visualization_0_min': '13000.0',
  'visualization_0_name': 'Land Surface Temperature',
  'visualization_0_palette': '040274,040281,0502a3,0502b8,0502ce,0502e6,0602ff,235cb1,307ef3,269db1,30c8e2,32d3ef,3be285,3ff38f,86e26f,3ae237,b5e22e,d6e21f,fff705,ffd611,ffb613,ff8b13,ff6e08,ff500d,ff0000,de0101,c21301,a71001,911003'},
 'type': 'ImageCollection',
 'version': 1621949182969935}

1 Answer 1

1

This is possible, but not for any larger number of pixels. Earth Engine will complain. In practice, you almost certainly would be better off exporting your imagery to Google Drive or Google Cloud Storage, then download them and process the imagery locally.

If you do want to play with extracting pixel values directly, here's how you can go ahead:

import ee
import numpy as np
import pandas as pd

ee.Initialize()


def mergeFeatures(feature, acc):
  feature = ee.Feature(feature)
  acc = ee.Dictionary(acc)
  
  def merge(key):
    return ee.List(feature.get(key)).cat(
      ee.List(acc.get(key))
    )

  return ee.Dictionary({
    'Lat': merge('Lat'),
    'Lon': merge('Lon'),
    'LstDay': merge('LstDay'),
    'Date': merge('Date')
  })


def toPixels(image):
  return ee.Feature(None, image
    .addBands(
      ee.Image.pixelLonLat()
        .rename(['Lon', 'Lat'])
    )
    .addBands(
      ee.Image(image.date().millis())
        .rename('Date')
    )
    .updateMask(image.mask())
    .reduceRegion(
      reducer=ee.Reducer.toList(), 
      geometry=geometry, 
      scale=10000, 
      maxPixels=1e13
    ) 
  )

# Small geometry of about 100km x 100km 
geometry = ee.Geometry.Point([0, 10]).buffer(1e5).bounds()

data_collection = ee.ImageCollection('MODIS/006/MOD11A1')\
  .filterDate('2020-01-01', '2020-01-08')\
  .filterBounds(geometry)\
  .select(['LST_Day_1km'], ['LstDay'])\
  .map(toPixels)
  
data_dictionary = ee.Dictionary(
  data_collection
    .filter(ee.Filter.notNull(['LstDay']))
    .iterate(mergeFeatures, {
      'Lat': [],
      'Lon': [],
      'LstDay': [],
      'Date': []
    })
).getInfo()

data_frame = pd.DataFrame(data_dictionary)

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.