Closed gaowudao closed 4 years ago
Do NOT post your Earth Engine token publicly!! This is a huge security risk. Anyone can use your token to access your GEE account. If the script does not work for you, you can retrieve the token from your computer and define it on your heroku app.
https://dashboard.heroku.com/apps
wow, Thank you very much and your suggestion. I will try.
This line in config_vars.py is throwing an error for me:
check_call(['heroku', 'config:set', secret], stdout=DEVNULL, stderr=STDOUT)
I'm on windows 10 and the error message is:
[WinError 2] The system cannot find the file specified
Checking the 'token' the slice is incorrect for the windows file. It should be:
token = content.split(':')[1][2:-2]
to include all characters excluding double quotation marks. The check_call will still throw an exception at this point.
Adding 'shell=True' to the check_call will work on windows (although this might be a security risk?)
check_call(['heroku', 'config:set', secret], stdout=DEVNULL, stderr=STDOUT, shell=True)
Setting the variable manually in Heroku does work.
Full working code for Windows 10:
import os
from subprocess import DEVNULL, STDOUT, check_call
def set_heroku_vars(token_name='EARTHENGINE_TOKEN'):
"""Extracts Earth Engine token from the local computer and sets it as an environment variable on heroku.
Args:
token_name (str, optional): Name of the Earth Engine token. Defaults to 'EARTHENGINE_TOKEN'.
"""
try:
ee_token_dir = os.path.expanduser("~/.config/earthengine/")
ee_token_file = os.path.join(ee_token_dir, 'credentials')
if not os.path.exists(ee_token_file):
print('The credentials file does not exist.')
else:
with open(ee_token_file) as f:
content = f.read()
token = content.split(':')[1][2:-2]
secret = '{}={}'.format(token_name, token)
check_call(['heroku', 'config:set', secret], stdout=DEVNULL, stderr=STDOUT, shell=True)
except Exception as e:
print(e)
return
if __name__ == '__main__':
set_heroku_vars(token_name='EARTHENGINE_TOKEN')
@Ojaybee Thank you very much for taking the time to debug the code and provide a working example. I did not realize that the credentials file on Linux is different from the one on Windows/macOS, which has an extra space in it. Therefore, the token slicing on Linux should be different from Windows/macOS. I have incorporated your solution and the config file now seems to run successfully on both Linux and Windows. Thanks.
Earth Engine App To authorize access needed by Earth Engine, open the following URL in a web browser and follow the instructions:
The authorization workflow will generate a code, which you should paste in the box below
I have added the key in Heroku config_vars but I am getting this error.
Use the following in your notebook before doing anything with ee. Otherwise, the authentication will fail.
import geemap Map = geemap.Map()
I am trying your examples. I have committed your code in my repo but I am not able to deploy it through my github repo. I have deployed the examples with your repo. It's giving problem in my repo my repo https://myfarm12.herokuapp.com/ is not working your repo https://powerful-retreat-90626.herokuapp.com/ is wroking fine
That mean your EE token was not set properly. Login to heroku to set the token manually. See https://github.com/giswqs/geemap-heroku/issues/1#issuecomment-656101951
I am able to do so .It's working fine.I want to update my live location on map.Can you please provide me any source code for Geemap.
Thanks for your quick response
What do you mean by 'live location'?
I want to update the live location on map like Google maps.
I just implemented this feature. Update the package using geemap.update_package()
and then use the following example to zoom to the map to the current device location.
import geemap
Map = geemap.Map()
Map.zoom_to_me(zoom=14, add_marker=True)
Map
Thanks I will check and get back to you
Location is not correct. I also want track my location on map like Google map
Try the example below. If it does not give you the correct location, then it is the problem of geocoder, not geemap.
import geocoder
g = geocoder.ip("me")
props = g.geojson["features"][0]["properties"]
lat = props["lat"]
lon = props["lng"]
print(lat, lon)
https://openlayers.org/workshop/en/mobile/compass.html Please check this documentation
I will try to run this code on mobile. I think It's not working due to laptop.
geemap is not designed for mobile use. It is not a GPS application. It does not use OpenLayers. geemap will not support getting live locations.
How to do it? I am making my project using your Geemap library only. Please guide me
I have done everything but my last part is to update the live location on map
I already told you. geemap does not support getting live locations. Period.
Ok 😔
Can you please tell me how to calculate the NDVI using planetscope imagery? I want to draw NDVI time series from planet scope imagery.
Hi Dr. Qiusheng Wu
I have deployed my application on heroku. Now I want to deploy my application on AWS.I am not able to set config_var.py file for AWS.
Can you please share any reference to deploy the project on AWS. Thanks
I have not deployed geemap on AWS before. You are welcome to explore it and provide the solution here if you figure it out.
I m getting problem to deploy EARTHENGINE_TOKEN in AWS
I can't put geemap key on github due to security reason.
I followed the steps to run the example. When excute the python config_vars.py, the error occured as follow:
Command '['heroku', 'config:set', 'EARTHENGINE_TOKEN="**]' returned non-zero exit status 1.