TransWikia.com

How do duplicate script on Google Earth Engine code editor

Geographic Information Systems Asked on August 15, 2021

I’m following https://docs.google.com/document/d/1bRCEB8ybRUp2D6vFc7mjqDMG2bpmCd2iTPQIEern0mk/edit#, its about classification and regression.

I followed the regression part then I’ll do the classification part.

To keep things organized I prefer to do the classification part in another file. But a lot of code can be reused. So I would like to duplicate script, how to?

I can copy paste code from one file to another. Problem is with the imports, at least I don’t know how to copy paste them to another file.

2 Answers

When trying to "duplicate script", you would want to take the approach of using the script modules

exports.doc = 'The Foo module is a demonstration of script modules.' +
'n It contains a foo function that returns a greeting string. ' +
'n It also contains a bar object representing the current date.' +
'n' +
'n foo(arg):' +
'n   @param {ee.String} arg The name to which the greeting should be addressed' +
'n   @return {ee.String} The complete greeting.' +
'n' +
'n bar:' +
'n   An ee.Date object containing the time at which the object was created.';

exports.foo = function(arg) {
return 'Hello, ' + arg + '!  And a good day to you!';
};

exports.bar = ee.Date(Date.now());

Also, I would suggest using this tutorial Making it easier to reuse code with Earth Engine script modules

A big challenge to using the Earth Engine Code Editor has been that your entire script has to fit in a single file. This can lead to very large scripts that are hard to manage and causes lots of copying and pasting between scripts if you want to repeat something that has already been done somewhere else.

To help with this problem, we’ve added a simple module loading system to help you reuse code. A “module” is just an ordinary script that’s identified some things it wants to export (see below).

Correct answer by whyzar on August 15, 2021

If you click the down arrow next to the save button, there is an option to "save as". This essentially creates a duplicate copy of your script that you can rename and change accordingly.

Answered by Aaron Merz on August 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP