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 2


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).


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.