@apburnes/astro-digital
A node client to the Astro Digital API
Last updated 5 years ago by apburnes .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @apburnes/astro-digital 
SYNC missed versions from official npm registry.

node-astro-digital

A node client to the Astor Digital API

Install

$ npm install @apburnes/astro-digital

new AstroDigital([options]);

Contstruct a new AstroDigital instace to publish and search scenes and metadata

Params

  • options: Object
    • limit: Integer - Default 25
    • skip: Integer - Default 0
    • apiVersion: String - Default 'v1'
var AstroDigital = require('@apburnes/astro-digital');

var options = {
  limit: '25', // Default string
  skip: '0', // Default string
  apiVersion: 'v1' // Default string and only version http://docs.astrodigital.com/v1.0/docs
};

var astro = new AstroDigital(options);

Publish API

astro.publish(email, sceneID, process, [satellite], [callback])

If callback is not given, astro.publish(email, sceneID, process) will return a promise.

Params

  • email: String of a valid email address
  • sceneID: String of a valid scene ID
  • process: String of valid process - options (trueColor, vegHealth, urbanFalse)
  • satellite: Optional String of satellite - Default l8 "Landsat 8"
  • callback: Optional Function - function(err, response, result)
var email = 'email@example.com';
var sceneID = 'LC80351142015001LGN00';
var processType = 'trueColor';
var satellite = 'l8';

// With a callback
astro.publish(email, sceneID, processType, satellite, function(err, response, result) {
  if (err) {
    // handle error
  }

  // result
});

// With a promise
astro.publish(email, sceneID, processType, satellite)
  .spread(function(response, result) {
    // handle result
  })
  .catch(function(err) {
    // handle error
  });

Search API

astro.search([query], [callback])

If query string is not given, astro.search(callback) will return the first 25 results of all scenes.

If callback is not given, astro.search(query) will return a promise.

Params

  • query: A query string following this syntax
  • callback: function(error, response, result)
var query = 'sceneID:LC80110442014358LGN00';

// With a callback
astro.search(query, function(err, response, result) {
  if (err) {
    // handle error
  }

  response =
  var metadata = data[1].meta // will be a meta data object about the query
});

// With a promise
astro.search(query)
  .spread(function(response, result) {
    // handle results
  })
  .catch(function(err) {
    // handle error
  });

Chaining Search Queries

astro.limit(count)

This method can be prepended in a chain before the search is called to change the default limit.

Params

  • count: Integer of number of results returned
astro
  .limit(100)
  .search(function(err, response, result) {
    if (err) {
      // handle error
    }

    results.results.length // equals the new limit of 100
  });

astro.skip(count)

This method can be prepended in a chain before the search is called to change the default skip.

Params

  • count: Integer of number of results skipped
astro
  .skip(100)
  .search(function(err, response, result) {
    if (err) {
      // handle error
    }

    result // will return an object
           // with the 'results' array of 25 results after the firstskipping 100
  });

astro.sceneId(scene)

This method can be prepended in a chain before the search is called to query scenes by ID or array of IDs.

Params

  • scene: Scene ID String or Array of Scene ID Strings
var scene = 'LC80110442014358LGN00';
// or
var scene = ['LC80110442014358LGN00', 'LC82281122014358LGN00'];

// With a callback
astro
  .sceneId(scene)
  .search(function(err, response, result) {
    if (err) {
      // handle error
    }

    // handle results
  });

// With a promise
astro
  .sceneId(scene)
  .search()
  .spread(function(response, result) {
    // handle response
  })
  .catch(function(err) {
    // handle error
  });

astro.row(rowNumber)

This method can be prepended in a chain before the search is called to query scenes by row.

Params

  • rowNumber: Number or Number String of the row
var rowNumber = 11;

astro
  .row(rowNumber)
  .search(function(err, response, result) {
    if (err) {
      // handle error
    }

    // handle results
  });

astro.path(pathNumber)

This method can be prepended in a chain before the search is called to query scenes by path.

Params

  • pathNumber: Number or Number String of the path
var pathNumber = 11;

astro
  .row(pathNumber)
  .search(function(err, response, result) {
    if (err) {
      // handle error
    }

    // handle results
  });

astro.rowAndPath(row, path)

This method can be prepended in a chain before the search is called to query scenes in row AND path.

Params

  • row: Number or Number String of the row
  • path: Number or Number String of the path
var row = 11;
var path = 2;

astro
  .rowAndPath(row, path)
  .search(function(err, response, result) {
    if (err) {
      // handle error
    }

    // handle results
  });

astro.rowOrPath(row, path)

This method can be prepended in a chain before the search is called to query scenes in row OR path.

Params

  • row: Number or Number String of the row
  • path: Number or Number String of the path
var row = 11;
var path = 2;

astro
  .rowOrPath(row, path)
  .search(function(err, response, result) {
    if (err) {
      // handle error
    }

    // handle results
  });

astro.cloudCover(range)

This method can be prepended in a chain before the search is called to query scenes within the cloud cover field range.

Params

  • range: Array of numbers of results returned
var range = [0, 20];

astro
  .cloudCover(range)
  .search(function(err, response, result) {
    if (err) {
      // handle error
    }

    results // returns scenes with 0% to 20% cloud cover
  });

astro.cloudCoverFull(range)

This method can be prepended in a chain before the search is called to query scenes within the cloud cover field range.

Same as astro.cloudCover(range)

astro.xy(longitude, latitude)

This method can be prepended in a chain before the search is called to query scenes that intersect the XY(longitude, latitude) point.

Params

  • longitude: Number representing the longitude
  • latitude: Number representing latitude
var long = -112.12;
var lat = 33.32;

astro
  .xy(long, lat)
  .search(function(err, response, result) {
    if (err) {
      // handle error
    }

    results // all scenes that intersect the XY point
  });

astro.bbox(xMin, yMin, xMax, yMax)

This method can be prepended in a chain before the search is called to query scenes that intersect the bounding box extent.

Params

  • xMin: Number representing the longitude minimum
  • yMin: Number representing the latitude minimum
  • xMax: Number representing the longitude maximum
  • yMax: Number representing the latitude maximum
var xMin = -100;
var yMin = 30;
var xMax = -80;
var yMax = 40;

astro
  .bbox(xMin, yMin, xMax, yMax)
  .search(function(err, response, result) {
    if (err) {
      // handle error
    }

    results // all scenes that intersect the bbox extent
  });

astro.queryField(field, value)

This method can be prepended in a chain before the search is called to query a field with a value.

Params

  • field: String of field name
  • value: String or Number of field value;
var field = 'sceneID';
var value = 'LC80110442014358LGN00';

astro
  .queryField(field, value)
  .search(function(err, response, result) {
    if (err) {
      // handle error
    }

    // handle result
  });

astro.queryRange(field, range)

This method can be prepended in a chain before the search is called to query a field with a value.

Params

  • field: String of field name
  • value: Array of field value range;
var field = 'cloudCover';
var range = [0, 20];

astro
  .queryField(field, range)
  .search(function(err, response, result) {
    if (err) {
      // handle error
    }

    // handle result
  });

astro.and()

This method can be prepended in a chain to filter scenes by fields using a sql like 'AND' operator.

// Finds scenes with cloud cover from 0% to 10% and between Jan 1, 2012 and Jan 1, 2014
// https://api.astrodigital.com/v1/search?search=cloudCover:[0+TO+50]+AND+acquisitionDate:[2012-01-01+TO+2014-01-01]

astro
  .cloudCover([0, 10])
  .and()
  .acquisitionDate(['2012-01-01', '2014-01-01'])
  .search(function(err, response, result) {
    if (err) {
      // handle error
    }

    // handle result
  });

astro.or()

This method can be prepended in a chain to filter scenes by fields using a sql like 'OR' operator.

// Finds scenes with cloud cover from 0% to 10% or 90% to 100%
// https://api.astrodigital.com/v1/search?search=cloudCover:[0+TO+10]+OR+cloudCover[90+TO+100]

astro
  .cloudCover([0, 10])
  .or()
  .cloudCover([90, 100])
  .search(function(err, response, result) {
    if (err) {
      // handle error
    }

    // handle result
  });

Methods API

astro.methods([callback])

If callback is not given, astro.methods() will return a promise.

Params

  • callback: Function [Optional] - function(err, response, result)
    • err: Error
    • response: Object - Request response information
    • result: Object - Scene processing methods available for satellites

Test

$ npm test

Contact

Andy B

Current Tags

  • 0.0.7                                ...           latest (5 years ago)

7 Versions

  • 0.0.7                                ...           5 years ago
  • 0.0.6                                ...           5 years ago
  • 0.0.5                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 7
Last Month 15
Dependencies (5)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |