def list_sets(args):
    adict = xml_downloader.get_dict()
    dataset = None
    if args.dataset:
        try:
            dataset = adict.keys()[int(args.dataset)]
        except:
            matches = filter(lambda z: z.startswith(args.dataset), adict.keys())
            if len(matches) == 1:
                dataset = matches[0]
            else:
                print "Too many matches:"
                print '\n'.join(matches)
                exit(1)

    if args.date and dataset:
        dates = adict[dataset]

        if args.date in dates:
            print "Downloading metadata xml..."
            dl_xml.download_xml(dataset, args.date)
        else:
            print "That date wasn't found"
    else:
        if dataset:
            data = adict[dataset]
        else:
            data = adict.keys()

        print '\n'.join(["%03d:  %s" % (a,b) for (a,b) in zip(range(0,len(adict.keys())), data)])
Beispiel #2
0
def list_sets(args):
    adict = xml_downloader.get_dict()
    dataset = None
    if args.dataset:
        try:
            dataset = adict.keys()[int(args.dataset)]
        except:
            matches = filter(lambda z: z.startswith(args.dataset),
                             adict.keys())
            if len(matches) == 1:
                dataset = matches[0]
            else:
                print "Too many matches:"
                print '\n'.join(matches)
                exit(1)

    if args.date and dataset:
        dates = adict[dataset]

        if args.date in dates:
            print "Downloading metadata xml..."
            dl_xml.download_xml(dataset, args.date)
        else:
            print "That date wasn't found"
    else:
        if dataset:
            data = adict[dataset]
        else:
            data = adict.keys()

        print '\n'.join([
            "%03d:  %s" % (a, b)
            for (a, b) in zip(range(0, len(adict.keys())), data)
        ])
def get_tile_names(dataset, date, latmin,lngmin,latmax,lngmax):

    p = pyproj.Proj("+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs")
    xmin,ymin = p(lngmin, latmin)
    xmax,ymax = p(lngmax, latmax)

    if xmin > xmax:
        t = xmax
        xmax = xmin
        xmin = t

    tilewidth = 1111950.5196666666
    xoffset = -20015109.354
    yoffset = -10007554.677

    xtilemin = int((xmin - xoffset) / tilewidth)
    ytilemin = 17 - int((ymax - yoffset) / tilewidth)

    xtilemax = int((xmax - xoffset) / tilewidth)
    ytilemax = 17 - int((ymin - yoffset) / tilewidth)

    xmlfiles = dl_xml.download_xml(dataset, date)

    tiles = []
    for x in range(xtilemin, xtilemax+1):
        for y in range(ytilemin, ytilemax+1):
            s = '.h%02dv%02d.' % (x,y)
            for xmlfile in xmlfiles:
                if s in xmlfile:
                    _, filename = os.path.split(xmlfile)
                    tiles.append('http://e4ftl01.cr.usgs.gov/MODIS_Composites/MOTA/%s/%s/%s' %
                                 (dataset, date, '.'.join(filename.split('.')[:-1])))
                    break

    return tiles
Beispiel #4
0
def get_tile_names(dataset, date, latmin, lngmin, latmax, lngmax):

    p = pyproj.Proj(
        "+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs"
    )
    xmin, ymin = p(lngmin, latmin)
    xmax, ymax = p(lngmax, latmax)

    if xmin > xmax:
        t = xmax
        xmax = xmin
        xmin = t

    tilewidth = 1111950.5196666666
    xoffset = -20015109.354
    yoffset = -10007554.677

    xtilemin = int((xmin - xoffset) / tilewidth)
    ytilemin = 17 - int((ymax - yoffset) / tilewidth)

    xtilemax = int((xmax - xoffset) / tilewidth)
    ytilemax = 17 - int((ymin - yoffset) / tilewidth)

    xmlfiles = dl_xml.download_xml(dataset, date)

    tiles = []
    for x in range(xtilemin, xtilemax + 1):
        for y in range(ytilemin, ytilemax + 1):
            s = '.h%02dv%02d.' % (x, y)
            for xmlfile in xmlfiles:
                if s in xmlfile:
                    _, filename = os.path.split(xmlfile)
                    tiles.append(
                        'http://e4ftl01.cr.usgs.gov/MODIS_Composites/MOTA/%s/%s/%s'
                        % (dataset, date, '.'.join(filename.split('.')[:-1])))
                    break

    return tiles