【发布时间】:2021-10-25 23:05:54
【问题描述】:
我正在尝试开发一个 nodejs 应用程序,该应用程序使用 Google 地球引擎进行一些地理空间数据分析。我正在使用 "@google/earthengine": "^0.1.185"、节点 v16.4.2 和 npm v 7.18.1。我还使用 gcloud 创建了服务帐户,并按照 Google Earth Engine npm installation 的步骤进行操作。问题是,每次我调用一些地球引擎功能时,它都会给出错误:
throw ee.initializationFailure_(e), e;
^
Error: Failed to contact Earth Engine servers. Please check your connection, firewall, or browser extension settings
在尝试连接到地球引擎时出现 404 错误之前。我试图停用我的防火墙以及更改我正在使用的互联网,但还是一样。 看下代码和报错:
const ee = require('@google/earthengine');
const path = require("path");
const express = require('express');
const app = express();
const privateKey = require('./privatekey.json');
const port = process.env.PORT || 4000;
app.set('views', __dirname + '/views');
//app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "html");
app.get('/', (_,res)=>{
res.sendFile('index.html', {root : __dirname + '/views'});
});
// Define endpoint at /mapid.
app.get('/mapid', (_, response) => {
// Instantiate an image with the Image constructor.
var image = ee.Image('CGIAR/SRTM90_V4');
// Zoom to a location.
Map.setCenter(-112.8598, 36.2841, 9); // Center on the Grand Canyon.
// Display the image on the map.
Map.addLayer(image);
});
console.log('Authenticating Earth Engine API using private key...');
ee.data.authenticateViaPrivateKey(
privateKey,
() => {
console.log('Authentication successful.');
ee.initialize(() => {
console.log('Earth Engine client library initialized.');
app.listen(port);
console.log(`Listening on port ${port}`);
},
(err) => {
console.log(err);
});
},
(err) => {
console.log(err);
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
错误
C:\blablablabla\node_modules\@google\earthengine\build\main.js:17724
throw ee.initializationFailure_(e), e;
^
Error: Failed to contact Earth Engine servers. Please check your connection, firewall, or browser extension settings.
at Object.ee.data.handleResponse_ (C:\blablablabla\node_modules\@google\earthengine\build\main.js:15467:9)
at Object.ee.data.send_ (C:\blablablabla\node_modules\@google\earthengine\build\main.js:15390:18)
at Object.ee.data.getAlgorithms (C:\blablablabla\node_modules\@google\earthengine\build\main.js:14670:24)
at Function.ee.ApiFunction.initialize (C:\blablablabla\node_modules\@google\earthengine\build\main.js:15923:78)
at Object.ee.initialize (C:\blablablabla\node_modules\@google\earthengine\build\main.js:17722:26)
at blablablabla\app.js:36:10
at Object.ee.data.handleAuthResult_ (C:\blablablabla\node_modules\@google\earthengine\build\main.js:15497:16)
at blablablabla\node_modules\@google\earthengine\build\main.js:14490:19
at blablablabla\node_modules\@google\earthengine\build\main.js:14424:41
at blablablabla\node_modules\google-auth-library\lib\auth\jwtclient.js:119:5
我真的需要你的帮助。
【问题讨论】:
-
你signup了吗?
-
是的,我做到了,它被证实了。我
-
您是否使用此代码测试过安装:developers.google.com/earth-engine/guides/…
-
是的@tttony,我尝试过但也遇到错误
throw ee.initializationFailure_(e), e; ^ Error: Server returned HTTP code: 404
标签: node.js google-maps google-cloud-platform google-earth-engine