Comments (21)
Since earthengine-api v0.1.383, users need to specify the project id for ee.Initialize()
, which is an extra barrier for ee Python users. Most Python users only have one cloud project (the default cloud project). It would be great if ee.Initialize()
can use the default cloud project under the user' account so that users don't have to specify the project id explicitly. It makes more sense to specify a project id only when a user has multiple cloud projects. Otherwise, the breaks most exsiting ee Python code.
ee.Initialize(project='my-project-id')
from geemap.
This bug has been fixed. Run pip install -U geemap
and restart the kernel to take effect.
from geemap.
@jdbcode I was thinking about having about a environment variable (e.g., EE_PROJECT_ID
) that can be accessed in Colab secrets. We can implement it in geemap before Colab officially supports it.
from geemap.
I can confirm that ee.Authenticate()
is broken for local Jupyter. It takes about 10 seconds to open the login page in the browser, which is significantly slower than previous versions. After that, it throws the invalid request
error. Authentication can't proceed. The same procesure works fine on Colab.
from geemap.
Hi @giswqs
Thank you for fixing this issue. We encountered the same issue in our project and used your solution, ee.Authenticate(auth_mode='localhost')
to fix it. It seems that specifying the project id to initialize with the code ee.Initialize(project='my-project-id')
only needs to be used for remote environments like google colab, but not local environments. For our project the code snippet below worked without having to specify a project id. I'm not sure exactly why this is the case.
ee.Authenticate(auth_mode='localhost')
ee.Initialize()
from geemap.
Running the following code should authenticate and initialize ee automatically. No need to run ee.Authenticate()
and ee.Initialize()
explictly.
import geemap
m = geemap.Map()
m
from geemap.
@jdbcode @naschmitz @schwehr Note that ee.Authenticate(auth_mode='notebook')
does not work any more. It needs to be fixed in the earthengine-api package.
from geemap.
Thank you so much!
from geemap.
@jdbcode @naschmitz @schwehr Note that ee.Authenticate(auth_mode='notebook') does not work any more. It needs to be fixed in the earthengine-api package.
Noted, we're looking, thanks for notifying!
from geemap.
For those that are trying to ee.Authenticate()
directly in a local Jupyter notebook (as opposed to allowing geemap to attempt it indirectly: m = geemap.Map()
), use ee.Authenticate(auth_mode='localhost')
for now, despite the auth docs currently saying that auth_mode='notebook'
should work.
from geemap.
@jdbcode geemap v0.30.2 already uses ee.Authenticate(auth_mode='localhost)
as a temporary fix. see here.
from geemap.
Also note that ee.Authenticate()
now takes about 10 seconds before openning up the browser. It used to be very fast, less than one second.
from geemap.
Nice! Thanks also for adding the if
for Colab!
However, I think the need for a project in initialization is also causing problems.
Testing from Colab:
(I made sure that it is not accessing stored credentials - deleted them temporarily)
!pip install -U geemap
import geemap
m = geemap.Map()
m
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
[<ipython-input-11-ef5c07d70876>](https://localhost:8080/#) in <cell line: 1>()
----> 1 m = geemap.Map()
2 m
[/usr/local/lib/python3.10/dist-packages/geemap/geemap.py](https://localhost:8080/#) in __init__(self, **kwargs)
155 # Default reducer to use
156 if kwargs["ee_initialize"]:
--> 157 self.roi_reducer = ee.Reducer.mean()
158 self.roi_reducer_scale = None
159
AttributeError: module 'ee' has no attribute 'Reducer'
I don't think it's initializing successfully and not showing the init error in stack trace.
from geemap.
Issue tracker for auth_mode='notebook'
not working: https://issuetracker.google.com/319451094
from geemap.
I can confirm that the colab auth is broken for geemap. Looking into it now.
from geemap.
Here is the workaround right now. I think the requirement for specifying a cloud project explicitly is a barrier for Python users. Most ee Python users probably only has one cloud project under their account, with default name like ee-<user-id>
. It would be easier if ee.Initialize()
user the default project for initialization. In this way, users don't have to login the Code Editor or Google Cloud to check the project id. If there are multiple projects or if ee API is not enabled for the default project, it then makes sense to throw the error message.
import geemap
geemap.ee_initialize(project='<your-project-id>')
m = geemap.Map()
m
from geemap.
The requirement for specifying a project-id will break all python examples in the documentation. Colab users will have to do one of the following to authenticate and initialize a session. It would be much easier if ee.Initialize()
just uses the user's default project rather than having to specify it explictly. In this way, it will not break existing code.
import ee
import geemap
ee.Authenticate(auto_mode='colab')
ee.Iinitialize(project='<your-project-id>')
m = geemap.Map()
m
import geemap
geemap.ee_initialize(project='<your-project-id>')
m = geemap.Map()
m
https://developers.google.com/earth-engine/guides/image_visualization#colab-python
from geemap.
@jdbcode Do you know what is the Python eqivalent to !gcloud projects list
? If the user only has one cloud project, it can be used as the default project for ee initialize. Otherwise, print out the list of project ids and alert users to choose a proper project id from the list to initialize. This is only need for Colab.
from geemap.
The auth_mode='notebook'
stills works for Colab, but not for local jupyter.
However, auth_mode='colab'
fails if the project id is not specified. Personally, I would prefer auth_mode='notebook'
because users don't have to leave Colab to go to the Code Editor or Google Cloud to find out the project id.
from geemap.
ee.Authenticate(auth_mode='notebook')
is working again for local Jupyter. It will allow you to select a project, which means you don't need to specify one in call to ee.Initialize()
.
https://issuetracker.google.com/319451094
If you are running locally though you might do auth and project setting through the command line once to save the credentials and then you only need to call ee.Initialize()
(without specifying project) or create a map in geemap for each new EE session. Read more here: https://developers.google.com/earth-engine/guides/auth#python_and_command_line
earthengine authenticate
earthengine set_project YOUR-EE-PROJECT
from geemap.
The requirement for specifying a project-id will break all python examples in the documentation. Colab users will have to do one of the following to authenticate and initialize a session. It would be much easier if
ee.Initialize()
just uses the user's default project rather than having to specify it explictly. In this way, it will not break existing code.
@giswqs - I agree, for a large group of users, having to specify a project in ee.Initialize(project='YOUR-EE-PROJECT')
is serious friction to getting going. With ee.Authenticate(auth_mode='notebook') that should not be a problem because they can select the project in the Auth UI and not need it when calling ee.Initialize()
. Cloud platform and projects are confusing, but they are here to stay, so I'm a little reluctant to hide them too much.
What I'd really like are for people to be able to access the Colab secrets through an API that allows a person to write for example earth engine credentials with the default project as an attribute. (so people don't have to run it in the command line locally and then copy/paste into colab) - then they should only have to ee.Initialize()
I think. We've heard from the Colab team that something like this might be possible, but need them to make changes, which could take some time.
from geemap.
Related Issues (20)
- checking lat/lon in module netcdf_to_ee converter HOT 3
- netcdf_to_ee code HOT 2
- No layer style UI for ee.ImageCollection
- Minor typo in "About" section of project homepage HOT 1
- View extent in cartoee module switched up HOT 4
- Histogram data output is empty when using a for loop HOT 5
- geemap.ee_to_pandas not available anymore? HOT 1
- Layer loading spinner proof-of-concept
- Change README from reStructureText to Markdown
- OEEL - Calling JavaScript functions from Python issue HOT 3
- shiny + geemap HOT 3
- Add functionality to load the overlay layer in the image_collection_gif
- GEE HTML Export error HOT 3
- Map object is not displaying HOT 2
- Unable to Render geemap Maps Correctly in Google Colab HOT 2
- cartoee issue HOT 3
- error with 'geemap.requireJS' HOT 5
- Error with import geemap on Jupyter Notebook HOT 3
- Cannot edit displayed speed unit "m/s" HOT 1
- geemap's add_data causes solara app to crash HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geemap.