@apburnes/astro-digital
v0.0.7
Published
A node client to the Astro Digital API
Downloads
6
Maintainers
Readme
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
: Objectlimit
: Integer - Default25
skip
: Integer - Default0
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 addresssceneID
: String of a valid scene IDprocess
: String of valid process - options (trueColor
,vegHealth
,urbanFalse
)satellite
: Optional String of satellite - Defaultl8
"Landsat 8"callback
: Optional Function -function(err, response, result)
var email = '[email protected]';
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 syntaxcallback
: 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 rowpath
: 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 rowpath
: 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 longitudelatitude
: 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 minimumyMin
: Number representing the latitude minimumxMax
: Number representing the longitude maximumyMax
: 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 namevalue
: 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 namevalue
: 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
: Errorresponse
: Object - Request response informationresult
: Object - Scene processing methods available for satellites
Test
$ npm test
Contact
Andy B