Masking datasets with different resolutions in GEE - resolution

I've calculated the NDMI index based on the MCD43A4 (spatial resolution 500m) collection for an area where various water bodies exist.
What I want to do, is to mask out these water bodies from my collection, based on the Landsat Global Inland Water dataset (spatial resolution 30m),
but I have no idea how to do this.
The first thing I must do, is to change the spatial resolution of Landsat in order to match it with the MODIS one but I do not understand
how to this, should I use a type of Reduce?
Thanks
var geometry = /* color: #d63000 */ee.Geometry.Polygon(
[[[69.75758392503599, 50.151303763817786],
[71.60328705003599, 40.18192251959151],
[93.70777923753599, 41.54446477874571],
[91.86207611253599, 51.09912927236651]]]);
var dataset = ee.ImageCollection('GLCF/GLS_WATER')
.filterBounds(geometry)
.map(function(image){return image.clip(geometry)}) ;
var water = dataset.select('water');
var imageCollection = ee.ImageCollection("MODIS/006/MCD43A4")
.filterBounds(geometry)
.map(function(image){return image.clip(geometry)})
.filter(ee.Filter.calendarRange(6,8,'month'));
var modNDMI = imageCollection.select("Nadir_Reflectance_Band2","Nadir_Reflectance_Band6","BRDF_Albedo_Band_Mandatory_Quality_Band2","BRDF_Albedo_Band_Mandatory_Quality_Band6");
/////////////////////////////////////////////////
var quality = function(image){
var mask1 = image.select("BRDF_Albedo_Band_Mandatory_Quality_Band2").eq(0);
var mask2 = image.select("BRDF_Albedo_Band_Mandatory_Quality_Band6").eq(0);
return image.updateMask(mask1).updateMask(mask2);
};
var clean_collection = modNDMI.map(quality);
var addNDMI = function(image) {
var ndmi = image.normalizedDifference(['Nadir_Reflectance_Band2', 'Nadir_Reflectance_Band6']).rename('NDMI');
return image.addBands(ndmi);
};
var ndmi = clean_collection.map(addNDMI);
var NDMI=ndmi.select('NDMI')
print(water)
//And from this point, I have no idea how to mask the water bodies based on the
//Landsat collection

It's not entirely obvious what you mean by "mask the waterbodies," but if this is not what you intend, then just use water_mask.not().
var gsw = ee.Image('JRC/GSW1_0/GlobalSurfaceWater');
var occurrence = gsw.select('occurrence');
// Create a water mask layer, and set the image mask so that non-water areas
// are opaque.
var water_mask = occurrence.gt(90).unmask(0);
Map.addLayer(water_mask)
var dataset = ee.ImageCollection('GLCF/GLS_WATER')
var water = dataset.select('water');
var imageCollection = ee.ImageCollection("MODIS/006/MCD43A4")
.filterDate('2017-01-01', '2018-12-31')
.filter(ee.Filter.calendarRange(6,8,'month'));
var modNDMI = imageCollection.select("Nadir_Reflectance_Band2","Nadir_Reflectance_Band6","BRDF_Albedo_Band_Mandatory_Quality_Band2","BRDF_Albedo_Band_Mandatory_Quality_Band6");
var quality = function(image){
var mask1 = image.select("BRDF_Albedo_Band_Mandatory_Quality_Band2").eq(0);
var mask2 = image.select("BRDF_Albedo_Band_Mandatory_Quality_Band6").eq(0);
return image.updateMask(mask1).updateMask(mask2);
};
var clean_collection = modNDMI.map(quality);
var addNDMI = function(image) {
var ndmi = image.normalizedDifference(['Nadir_Reflectance_Band2', 'Nadir_Reflectance_Band6']).rename('NDMI');
return image.addBands(ndmi).updateMask(water_mask);
};
var ndmi = clean_collection.map(addNDMI);
var NDMI=ndmi.select('NDMI')
Map.addLayer(NDMI)
See also this tutorial.

Related

how can i split the data in a var and push to an array in nodejs

I have tried the below code, to split the latitude and longitude values, but its more complex. Is there any easy ways. Below shown is my code. I have used many replace functions as well split functions...
var data = [{"latitude":1.9,"longitude":103.57},{"latitude":1.338,"longitude":103.1},{"latitude":1.33,"longitude":103.7556}]
var re3 = /[\"\'\ ]+/g
data = data.replace(re3,'')
var re2 = /[\[\]\ ]+/g
data = data.replace(re2,'"')
var re1 = /[\'\r'\'\n'\{\ ]+/g
var data = data.replace(re1, '')
var re = /[\{\ ]+/g
var data = data.replace(re, '')
var re4 = /},/g
data = data.replace(re1, ';')
var re5 = /[\}\"\ ]+/g
data = data.replace(re, '')
let value = data.split(';');
console.log(value)
let valueArr = [];
value.forEach(geo => {
if (geo) {
let l = geo.split(',');
valueArr.push({
latitude: latLong[0],
longitude: latLong[1],
});
}
});
I would like to get output like
latitude: 1.9,
longitude: 1
and so on in the arr
03.57
That data seems to be in JSON format. Use JSON.parse().
var data = JSON.parse('[{"latitude":1.9,"longitude":103.57},{"latitude":1.338,"longitude":103.1},{"latitude":1.33,"longitude":103.7556}]');
console.log(data[0].latitude, data[0].longitude);

Pixi.js v5 - apply alpha to displacement map

I'm scaling a displacement map on click but would like that map to fade away once it reaches almost full scale. The idea is that the filter should be non-existent after a couple of seconds.
const app = new PIXI.Application({
view: document.querySelector("#canvas"),
width: 512,
height: 512
});
const logo = PIXI.Sprite.fromImage("https://unsplash.it/600");
const displacement = PIXI.Sprite.fromImage("https://images.unsplash.com/photo-1541701494587-cb58502866ab?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80");
const filter = new PIXI.filters.DisplacementFilter(displacement);
logo.anchor.set(0.5);
logo.position.set(256);
logo.interactive = true;
displacement.anchor.set(0.5);
displacement.position.set(256);
displacement.scale.set(0.05)
displacement.alpha = 1
app.stage.filterArea = app.screen;
app.stage.filters = [filter];
app.stage.addChild(logo, displacement);
app.ticker.add(function() {
displacement.scale.x += 0.05
displacement.scale.y += 0.05
if (displacement.scale.x > 10) app.ticker.stop()
});
logo.on('mousedown', function() {
displacement.scale.set(0.05)
app.ticker.start()
});
Here's what I have so far:
https://codepen.io/mariojankovic/pen/pojjNae?editors=0111
I've only just started looking at Pixi but I think you want to use the scale property of the displacement filter. This value says how far to shift. Reducing this value to 0 will lessen its effect to none.
https://pixijs.download/dev/docs/PIXI.filters.DisplacementFilter.html
https://pixijs.download/dev/docs/PIXI.filters.DisplacementFilter.html#scale
The way it works is it uses the values of the displacement map to look
up the correct pixels to output. This means it's not technically
moving the original. Instead, it's starting at the output and asking
"which pixel from the original goes here". For example, if a
displacement map pixel has red = 1 and the filter scale is 20, this
filter will output the pixel approximately 20 pixels to the right of
the original.
https://codepen.io/PAEz/pen/BaoREwv
const app = new PIXI.Application({
view: document.querySelector("#canvas"),
width: 512,
height: 512
});
const logo = PIXI.Sprite.fromImage("https://unsplash.it/600");
const displacement = PIXI.Sprite.fromImage(
"https://images.unsplash.com/photo-1541701494587-cb58502866ab?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80"
);
const filter = new PIXI.filters.DisplacementFilter(displacement);
logo.anchor.set(0.5);
logo.position.set(256);
logo.interactive = true;
displacement.anchor.set(0.5);
displacement.position.set(256);
displacement.scale.set(0.0);
displacement.alpha = 1;
app.stage.filterArea = app.screen;
app.stage.filters = [filter];
app.stage.addChild(logo, displacement);
const displacementScaleFrom = 0.05;
const displacementScaleTo = 10 ;
const displacementStep = 0.05;
const filterScaleFrom = 20;// the default value for the filter is 20
const filterStep = filterScaleFrom / ((displacementScaleTo-displacementScaleFrom) / displacementStep);
app.ticker.add(function () {
displacement.scale.x += displacementStep;
displacement.scale.y += displacementStep;
filter.scale.x -= filterStep;
filter.scale.y -= filterStep;
if (displacement.scale.x >= displacementScaleTo) {
app.ticker.stop();
filter.scale.x = 0;
filter.scale.y = 0;
}
});
logo.on("mousedown", function () {
displacement.scale.set(displacementScaleFrom);
filter.scale.x = filterScaleFrom;
filter.scale.y = filterScaleFrom;
app.ticker.start();
});

How to add extra filter and columns into existing saved searches while loading in Netsuite 2.0

I have the following SuiteScript 2.0 code in a UserEvent where I would like to add an additional filter and columns to the loaded saved search.
A filter is working properly but how to get column value from Array which is added as an extra column in Saved search.
var filters = [];
filters.push(
['memo', 'is', 'Updated']
);
var filters = [];
filters.push(
['memo', 'is', 'Updated']
);
var columnsCust = [];
columnsCust.push(search.createColumn({
name: 'trandate'
}));
var mySearch = search.load({
id: 'customsearch_so_savedsearch'
});
//Add filters
mySearch.filterExpression = filters;
var filtersResult = mySearch.filterExpression;
//Add columns
mySearch.column = columnsCust;
var columnResult = mySearch.column;
var searchResult = mySearch.run().getRange({start: 0,end: 10});
for (var i = 0; i < searchResult.length; i++)
{
var date = searchResult[i].getValue({name: 'trandate'});
log.debug('date::' + date); //date::null
//it gives transactionnumber value Because this column exist in Saved
//search.
var transactionnumber = searchResult[i].getValue({name: 'transactionnumber'});
log.debug('transactionnumber::' + transactionnumber); //transactionnumber::112513
}
To add extra columns, filters or filterExpressions in a search object, firsrt you need to fetch the object from search-object and then update it.
For Search Columns
var searchColumns = mySearch.columns;
searchColumns.push(AdditionalColumns);
mySearch.columns = searchColumns;
For Search Filters
var searchFilters = mySearch.filters;
searchFilters.push(additionalFilters);
mySearch.filters = searchFilters;
For FilterExpressions
var searchFilterExpression = mySearch.filterExpression;
// push operator if searchObject contains filters
if (searchFilterExpression.length > 0) {
searchFilterExpression.push('and');
}
searchFilterExpression.push(additionalFilterExpression);
mySearch.filterExpression = searchFilterExpression;
Note: Check this out for further reading.

Pulling Quantity Pricing through Suitescript?

Looking to see if anyone has an example to pull Quantity Pricing from an item record with SuiteScript? I haven't been able to find anything online and don't even know how that would build out if it was SuiteScripted (since the qty is different per item). Anyone have anything that can show me how to do this?
Part of the issue with supplying sample code is that the code will be different depending on whether you also have multiple currencies available.
If you only have one currency you can get the prices for the price breaks as follows, The endpriceX values indicate the last quantity the associated price is applicable to:
strprice1 = myitem.getFieldValue('pricequantity1');
var valprice1 = myitem.getLineItemMatrixValue('price', 'price', lineno, 1);
valprice1 = parseFloat(valprice1);
var strprice2 = myitem.getFieldValue('pricequantity2');
var valprice2 = myitem.getLineItemMatrixValue('price', 'price', lineno, 2);
var endprice1 = parseInt(strprice2) - 1;
valprice2 = parseFloat(valprice2);
var strprice3 = myitem.getFieldValue('pricequantity3');
var endprice2 = parseInt(strprice3) - 1;
var valprice3 = myitem.getLineItemMatrixValue('price', 'price', lineno, 3);
valprice3 = parseFloat(valprice3);
var strprice4 = myitem.getFieldValue('pricequantity4');
var endprice3 = parseInt(strprice4) - 1;
var valprice4 = myitem.getLineItemMatrixValue('price', 'price', lineno, 4);
valprice4 = parseFloat(valprice4);
var strprice5 = myitem.getFieldValue('pricequantity5');
var endprice4 = parseInt(strprice5) - 1;
var valprice5 = myitem.getLineItemMatrixValue('price', 'price', lineno, 5);
valprice5 = parseFloat(valprice5);

How to set right alignment of some text using NotesRichTextParagraphStyle

var currDb:NotesDatabase = session.getCurrentDatabase();
var emailDoc:NotesDocument = database.createDocument();
var mailRTItem:NotesRichTextItem = emailDoc.createRichTextItem("Body");
var mStyle:NotesRichTextStyle = session.createRichTextStyle();
var r:NotesRichTextParagraphStyle = session.createRichTextParagraphStyle();
mStyle.setBold(1);
mailRTItem.appendStyle(mStyle);
mailRTItem.appendText(#Text("Dear Concerned,"));
mailRTItem.addNewLine(2);
r.setRightMargin(1);
mailRTItem.appendParagraphStyle(r);
mailRTItem.appendText("Text That is required to be right aligned");
emailDoc.save();
Replace your code line
r.setRightMargin(1);
with the line
r.setAlignment(NotesRichTextParagraphStyle.ALIGN_RIGHT);
This will set the right alignment.

Resources