JAXA Earth API for JavaScript
    Preparing search index...

    Class ImageCollection

    The ImageCollection class that stores information about a dataset. It mainly handles date/time and band information.

    You create an instance by specifying the URL of the dataset's collection.json, and complete the preparation by running init.

    After that, you can search for the date/times available in this dataset using first, last, prev, next, and so on, and then retrieve an Image by running getImage with a specified date/time and band name.

    import * as je from "./jaxa.earth.esm.js";

    // Specify the collection.json to identify the dataset you want to use.
    const collectionUrl = "https://s3.ap-northeast-1.wasabisys.com/je-pds/cog/v1/JAXA.G-Portal_GCOM-W.AMSR2_standard.L3-SMC.daytime.v3_global_monthly/collection.json";

    // Create and initialize an ImageCollection. Initialization loads the necessary information from collection.json.
    const ic = new je.ImageCollection({ collectionUrl });
    await ic.init();

    // Retrieve the first date/time.
    console.log(ic.first());
    console.log(ic.formatDate(ic.first()));

    // Retrieve the last date/time.
    console.log(ic.last());
    console.log(ic.formatDate(ic.last()));

    // Retrieve the date/time before the specified date/time. Since the search communicates through the catalog file, await must be specified.
    console.log(await ic.prev(new Date(Date.UTC(2023, 2 - 1))));

    // Retrieve the date/time after the specified date/time. Since the search communicates through the catalog file, await must be specified.
    console.log(await ic.next(new Date(Date.UTC(2023, 2 - 1))));

    // Retrieve the date/times within the specified date/time range for which data exists.
    console.log(await ic.getDateAll(
    new Date(Date.UTC(2020, 1 - 1, 1)), //start (this value is included)
    new Date(Date.UTC(2022, 1 - 1, 1)), //end (this value is not included)
    ));

    // Retrieve the available band names.
    console.log(ic.getBandIdAll());

    // Retrieve a je.Image from the ImageCollection.
    const im = await ic.getImage({
    // Specify the date/time. The data for the specified date/time is retrieved. If omitted, the current date/time is used, so the latest data can be retrieved.
    // In this example, the data for 2021/6 is retrieved.
    date: new Date(Date.UTC(2021, 6 - 1)),

    // Specify the band name. If omitted, the first band name is automatically selected.
    band: "SMC",
    });
    Index

    Constructors

    • Parameters

      • options: { collectionUrl: string }
        • collectionUrl: string

          The URL of the dataset's collection.json.

      Returns ImageCollection

    Methods

    • Loads the collection.json specified by collectionUrl and prepares this instance so that it can be used.

      Returns Promise<void>

    • Returns the string representation of a date/time. It converts the date/time into a string representation that reflects the dataset's specific time interval, for example "YYYY/MM" for a monthly dataset, "YYYY/MM/DD" for a daily dataset, and "MM" for a climatology value (such as an average obtained from multiple years of data).

      Parameters

      • date: Date

      Returns string

    • Returns the first available date/time.

      Returns Date

    • Returns the last available date/time.

      Returns Date

    • Returns the date/time for which data exists before the date/time specified in the argument. Since the search communicates through the catalog file, it returns a Promise.

      Parameters

      • date: Date

      Returns Promise<Date>

    • Returns the date/time for which data exists after the date/time specified in the argument. Since the search communicates through the catalog file, it returns a Promise.

      Parameters

      • date: Date

      Returns Promise<Date>

    • Returns all date/times of data contained within the specified date/time range (start <= Date < end).

      Parameters

      • start: Date

        The start date/time for searching date/times.

      • end: Date

        The end date/time for searching date/times. (This date/time is not included.)

      Returns Promise<Date[]>

    • Returns the string representations of all date/times of data contained within the specified date/time range (start <= Date < end).

      Parameters

      • start: Date

        The start date/time for searching date/times.

      • end: Date

        The end date/time for searching date/times. (This date/time is not included.)

      Returns Promise<string[]>

    • Returns all band names available in this ImageCollection. They can be retrieved as a string array that preserves the order of the band names defined in collection.json.

      Returns string[]

      An array of available band names

    • Retrieves the Image for the specified date/time and band name.

      The date/time specification works as follows.

      • If data exists at the specified date/time, that data is returned.
      • If the specified date/time has a fractional part and no exact data exists at that pinpoint, it is rounded to point to the immediately preceding data. For example, for monthly data, if 2025/02/05 12:00 is specified, 2025/02 is selected.
      • If omitted, the current date/time new Date() is used, so the most recent data can be retrieved.

      The band name specification works as follows.

      • If specified, the data for that band name is returned.
      • If omitted, the first band name defined in collection.json is automatically selected.

      Parameters

      • options: { date?: Date; band?: string }
        • Optionaldate?: Date

          Specifies the date/time.

        • Optionalband?: string

          Specifies the band name.

      Returns Promise<Image>