-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0533f85
commit be8f405
Showing
27 changed files
with
132 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import stat from "../stat"; | ||
|
||
/** | ||
* The range function takes a georaster as an input and an optional geometry. | ||
* If a geometry is included, the function returns the range of all the pixels | ||
* in that area for each band. If no geometry is included, the function returns the range of | ||
* all the pixels for each band in the raster. | ||
* @name min | ||
* @param {GeoRaster|ArrayBuffer|Blob|Buffer|File|String} georaster - geospatial gridded raster data | ||
* @param {Object} geometry - geometry can be an [xmin, ymin, xmax, ymax] array for a bounding box, [[[x00,y00],...,[x0n,y0n],[x00,y00]]...] for a polygon, a GeoJSON polygon object, or a string representation of a GeoJSON polygon object. | ||
* @returns {Number[]} array of ranges for each band | ||
* @example | ||
* // naip.tif has 4-bands: red, green, blue and near-infrared (nir) | ||
* const url = "https://example.org/naif.tif"; | ||
* | ||
* const ranges = await geoblaze.range(url, geometry); | ||
* // ranges is [red, green, blue, nir] | ||
* [231, 234, 229, 0] | ||
*/ | ||
|
||
export default function range(georaster, geometry, test) { | ||
return stat(georaster, geometry, "range", test); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import test from "flug"; | ||
import { serve } from "srvd"; | ||
import range from "./index"; | ||
|
||
serve({ debug: true, max: 10, port: 3000 }); | ||
|
||
const url = "http://localhost:3000/data/test.tiff"; | ||
const bbox = [80.63, 7.42, 84.21, 10.1]; | ||
const expectedBboxValue = 5166.7; | ||
|
||
const polygon = [ | ||
[ | ||
[83.12255859375, 22.49225722008518], | ||
[82.96875, 21.57571893245848], | ||
[81.58447265624999, 1.207458730482642], | ||
[83.07861328125, 20.34462694382967], | ||
[83.8037109375, 19.497664168139053], | ||
[84.814453125, 19.766703551716976], | ||
[85.078125, 21.166483858206583], | ||
[86.044921875, 20.838277806058933], | ||
[86.98974609375, 22.49225722008518], | ||
[85.58349609375, 24.54712317973075], | ||
[84.6826171875, 23.36242859340884], | ||
[83.12255859375, 22.49225722008518] | ||
] | ||
]; | ||
|
||
test("(Modern) Get Range from Bounding Box", async ({ eq }) => { | ||
const results = await range(url, bbox); | ||
const value = Number(results[0].toFixed(2)); | ||
eq(value, expectedBboxValue); | ||
}); | ||
|
||
test("(Modern) Get Range from Polygon", async ({ eq }) => { | ||
const results = await range(url, polygon); | ||
const value = Number(results[0].toFixed(2)); | ||
eq(value, 7807.4); | ||
}); | ||
|
||
test("(Modern) Get Range from whole Raster", async ({ eq }) => { | ||
const results = await range(url); | ||
eq(results, [8131.2]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* The stat function takes a georaster and an optional geometry. | ||
* It then uses the <a href="https://github.com/DanielJDufour/calc-stats" target="_blank">calc-stats</a> library | ||
* to calculate statistics for each band. | ||
* @name stat | ||
* @param {GeoRaster|ArrayBuffer|Blob|Buffer|File|String} georaster - geospatial gridded raster data | ||
* @param {Object} geometry - geometry can be an [xmin, ymin, xmax, ymax] array for a bounding box, [[[x00,y00],...,[x0n,y0n],[x00,y00]]...] for a polygon, a GeoJSON polygon object, or a string representation of a GeoJSON polygon object. | ||
* @param {String} stat - name of statistic according to <a href="https://github.com/DanielJDufour/calc-stats" target="_blank">calc-stats</a> | ||
* @returns {Object} array of stat for each band | ||
* @example | ||
await geoblaze.stat("https://example.org/rgb.tif", geometry, "median"); | ||
[22, 32, 34] | ||
*/ | ||
export { default } from "./stat.module"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import QuickPromise from "quick-promise"; | ||
import stats from "../stats"; | ||
|
||
export default function stat(georaster, geometry, stat, test) { | ||
return QuickPromise.resolve(stats(georaster, geometry, { stats: [stat] }, test)).then(stats => stats.map(it => it[stat])); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters