admin管理员组文章数量:1318570
In Google Earth Engine I need to generate a file name from a ee.Date
object.
I have the following code in Google Earth Engine:
var date_object = ee.Date.fromYMD(2017,12, 1);
var date_string = date_object.format("YYYY-MM-dd");
print(date_string);
file_name = "my_file_" + date_string;
print(file_name);
The output of print(date_string)
looks OK:
2017-12-01
But the output of print(file_name) is:
ee.String({
"type": "Invocation",
"arguments": {
"date": {
"type": "Invocation",
"arguments": {
"year": 2017,
"month": 12,
"day": 1
},
"functionName": "Date.fromYMD"
},
"format": "YYYY-MM-dd"
},
"functionName": "Date.format"
})
I expected I would get the output my_file_2017-12-01
. How do I use the "+" operator with ee.String
object in Google EarthEngine to concatenate two strings?
In Google Earth Engine I need to generate a file name from a ee.Date
object.
I have the following code in Google Earth Engine:
var date_object = ee.Date.fromYMD(2017,12, 1);
var date_string = date_object.format("YYYY-MM-dd");
print(date_string);
file_name = "my_file_" + date_string;
print(file_name);
The output of print(date_string)
looks OK:
2017-12-01
But the output of print(file_name) is:
ee.String({
"type": "Invocation",
"arguments": {
"date": {
"type": "Invocation",
"arguments": {
"year": 2017,
"month": 12,
"day": 1
},
"functionName": "Date.fromYMD"
},
"format": "YYYY-MM-dd"
},
"functionName": "Date.format"
})
I expected I would get the output my_file_2017-12-01
. How do I use the "+" operator with ee.String
object in Google EarthEngine to concatenate two strings?
1 Answer
Reset to default 10What you see is a proxy. This is explained in the following documentation page: https://developers.google./earth-engine/client_server. Adding getInfo() fixes the error:
file_name = "my_file_" + date_string.getInfo();
https://code.earthengine.google./e61868ab3f333e8f2d19afd96b396964
And for the server-side EE code, as suggested by Nick:
file_name = ee.String('my_file_').cat(date_string);
https://code.earthengine.google./4812bb27a2869bd71771b067abd410e0
本文标签: javascriptHow do I use the quotquot operator to concatenate two stringsStack Overflow
版权声明:本文标题:javascript - How do I use the "+" operator to concatenate two strings? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742047551a2417878.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论