Skip to content

Commit

Permalink
Add NAMMA campaign data and adapt code to process it
Browse files Browse the repository at this point in the history
  • Loading branch information
willemarcel committed May 20, 2024
1 parent fa0e7a9 commit fa0773c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
19 changes: 19 additions & 0 deletions campaigns/NAMMA/deployments.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
deployments:
- name: NAMMA-D1_2006
platforms:
- name: DC-8
files:
- https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060912_larc.csv
- https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060909_larc.csv
- https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060908_larc.csv
- https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060905_larc.csv
- https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060904_larc.csv
- https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060903_larc.csv
- https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060901_larc.csv
- https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060830_larc.csv
- https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060826_larc.csv
- https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060825_larc.csv
- https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060823_larc.csv
- https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060820_larc.csv
- https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060819_larc.csv
13 changes: 12 additions & 1 deletion task/src/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ const makeStaticLocationsGeoJSON = (filePath) => {
* @param {Object} extraProperties - predefined properties
* @param {Array} columnsStats - an array containing the columns that will have the stats computed.
Stats include the average, minimum and maximum values.
* @param {Number} coordsDivisor - an optional integer number. Case informed,
all coordinates values will be divided by it.
* @param {Boolean} fixCoords - if true, coordinates that seems to be wrong will be removed.
See cleanCoords function.
* @return {Object} resulting GeoJSON object
Expand All @@ -170,15 +172,24 @@ const makeGeoJSON = (
) => {
const file = fs.readFileSync(filePath);
const content = file.toString();
// configure latitude and longitude fields
let latField = 'latitude';
let lonField = 'longitude';
if (content.includes('Latitude,') && content.includes('Longitude,')) {
latField = 'Latitude';
lonField = 'Longitude';
}

let geojson;
csv2geojson.csv2geojson(
content,
{ latfield: 'latitude', lonfield: 'longitude', delimiter: ',' },
{ latfield: latField, lonfield: lonField, delimiter: ',' },
(err, data) => geojson = data
);
if (coordsDivisor) {
geojson.features = divideCoordinates(geojson.features, coordsDivisor);
}
// remove invalid coordinates
geojson.features = geojson.features.filter((i) => (
i.geometry.coordinates[0] >= -180 && i.geometry.coordinates[1] >= -90
&& i.geometry.coordinates[0] <= 180 && i.geometry.coordinates[1] <= 90
Expand Down

0 comments on commit fa0773c

Please sign in to comment.