Exemplo n.º 1
0
def get_lc(year, tile, fips):
    '''
    Return LC mask for year,tile,fips
    '''
    kwargs = {
        'tile': tile,
        'product': 'MCD12Q1',
    }
    doy = 1
    # get the LC data
    modis = Modis(**kwargs)

    warp_args = {
        'dstNodata': 255,
        'format': 'MEM',
        'cropToCutline': True,
        'cutlineWhere': f"FIPS='{fips}'",
        'cutlineDSName': 'data/TM_WORLD_BORDERS-0.3.shp'
    }

    # specify day of year (DOY) and year
    lcfiles = modis.get_modis(year, doy, warp_args=warp_args)
    # get the item we want
    g = gdal.Open(lcfiles['LC_Type3'])
    # error checking
    if not g:
        print(f"cannot open LC file {lcfiles['LC_Type3']}")
        return None
    lc = g.ReadAsArray()
    del g

    # in your function, print out the unique values in the
    # landcover dataset to give some feedback to the user
    print(f"class codes: {np.unique(lc)}")
    return lc
Exemplo n.º 2
0
def pull(year, tile=['h09v05'], doy="*", month=None, day=None, step=1):
    product = 'MYD10A1'
    kwargs = {'tile': list(tile), 'product': product, 'verbose': True}
    # get the data
    print(kwargs)
    modis = Modis(**kwargs)
    mfiles = modis.get_modis(year, doy, step=step)
    return mfiles
Exemplo n.º 3
0
def modis_annual_dataset(year, tile, product, step=1, verbose=False):
    # load into kwargs
    kwargs = {
        'verbose': verbose,
        'tile': list(tile),
        'product': product,
    }
    # list of doys we want
    doys = "*"

    modis = Modis(**kwargs)
    ifiles = modis.get_modis(year, doys, step=step)
    return ifiles
Exemplo n.º 4
0
at the command prompt.
'''

import gdal
try:
    from geog0111.modis import Modis
except:
    from modis import Modis
import matplotlib.pyplot as plt

kwargs = {
    'verbose': True,
    'tile': ['h17v03', 'h18v03', 'h17v04', 'h18v04'],
    'product': 'MCD15A3H',
}
year = 2018
# list of doys we want
doys = "*"

modis = Modis(**kwargs)

warp_args = {
    'dstNodata': 255,
    'format': 'MEM',
    'cropToCutline': True,
    'cutlineWhere': "FIPS='UK'",
    'cutlineDSName': 'data/TM_WORLD_BORDERS-0.3.shp'
}
mfiles = modis.get_modis(year, doys, warp_args=warp_args, step=4)
print(mfiles.keys())
Exemplo n.º 5
0
'''
Example script to get all days of data for MCD15A3H
for the tiles and year spewcified. 


To run this, simply type:

geog0111/get_lai.py

at the command prompt.
'''

from osgeo import gdal
try:
    from geog0111.modis import Modis
except:
    from modis import Modis
import matplotlib.pyplot as plt

kwargs = {
    'verbose': True,
    'tile': ['h17v03', 'h18v03', 'h17v04', 'h18v04'],
    'product': 'MCD15A3H',
}
for year in [2017, 2018, 2019]:
    # list of doys we want
    doys = "*"
    modis = Modis(**kwargs)
    mfiles = modis.get_modis(year, doys, step=4)
    print(mfiles.keys())