gee-community/geemap

cartoee issue

caomy7 opened this issue · 5 comments

Environment Information

geemap = 0.32.0
Cartopy =0.23.0

Please run the following code on your computer and share the output with us so that we can better debug your issue:

import ee
import geemap
import cartopy.crs as ccrs
# import the cartoee functionality from geemap
from geemap import cartoee
import matplotlib.pyplot as plt


fig = plt.figure(figsize=(10, 8))
# roi = ee.FeatureCollection("users/Molly_HK/daymet_area")

image = crossCorr.clip(roi)

vis = {
  'min': -1,
  'max': 1,
  'palette': ['4AAAF7',"4AE7F7", 'D3D1CD',"FFB833",'FF5B33']

}

ax = cartoee.get_map(crossCorr, region=[-30.0, 0, -180.0, 90], vis_params=vis) #[E,S,W,N]
ax = cartoee.add_colorbar(ax, vis, loc="bottom", label="Correlation", orientation="horizontal")

plt.show()

Description

I want to visualize the image using cartopy.
The image shows OK in the geemap.
It seems to have a problem when I run the above code and get the error as follow:
"HTTPError Traceback (most recent call last)
in <cell line: 21>()
19 }
20
---> 21 ax = cartoee.get_map(crossCorr, region=[-30.0, 0, -180.0, 90], vis_params=vis) #[E,S,W,N]
22 ax = cartoee.add_colorbar(ax, vis, loc="bottom", label="Correlation", orientation="horizontal")
23

1 frames
/usr/local/lib/python3.10/dist-packages/geemap/cartoee.py in add_layer(ax, ee_object, dims, region, cmap, vis_params, **kwargs)
273 if response.status_code != 200:
274 error = eval(response.content)["error"]
--> 275 raise requests.exceptions.HTTPError(f"{error}")
276
277 image = np.array(Image.open(BytesIO(response.content)))

HTTPError: {'code': 500, 'message': 'An internal error has occurred (request: 39097224-ab9e-4b03-a3f2-dbf977d5c506) (computation: "aa777aa76dc125ee590c2b234050d55a")', 'status': 'INTERNAL'}"

What I Did

It worked before, but now it doesn't seem to work.

how to change the projection from 'crs': 'SR-ORG:6974' to 'crs': 'EPSG:4326'.

Please a complete script that can reproduce the issue. Incomplete script with undefined variables is not helpful.

Try the following script. If it works, then it is likely your own script problem.

import ee
import geemap
from geemap import cartoee 
import matplotlib.pyplot as plt

geemap.ee_initialize()

# get an image
srtm = ee.Image("CGIAR/SRTM90_V4")

# geospatial region in format [E,S,W,N]
region = [180, -60, -180, 85]  # define bounding box to request data
vis = {"min": 0, "max": 3000}  # define visualization parameters for image

fig = plt.figure(figsize=(15, 10))

# use cartoee to get a map
ax = cartoee.get_map(srtm, region=region, vis_params=vis)

# add a colorbar to the map using the visualization params we passed to the map
cartoee.add_colorbar(ax, vis, loc="bottom", label="Elevation", orientation="horizontal")

# add gridlines to the map at a specified interval
cartoee.add_gridlines(ax, interval=[60, 30], linestyle=":")

# add coastlines using the cartopy api
ax.coastlines(color="red")

plt.show()