I try to convert raster tif or netcdf file to ee.Image Google Earth Engine object in Python. The netcdf raster testing data (5-bands) is in this link. Here I converted the first band from raster file to ee.Image but throwed errors indicating invalid data types.

import rioxarray
import ee
import xarray as xr
ds=rioxarray.open_rasterio("testdata.nc", masked=True)
# Rename 
# Select the first band and convert it to GEE image


1 Answer 1


You are trying to create a server-side object (ee.Image) with a client-side file. Please read Client vs. Server for understanding how GEE works.

Since ee.Image is a server-side function, check what kind of inputs it accepts:


An object to represent an Earth Engine image. This constructor accepts a variety of arguments:

  • A string: an EarthEngine asset id,

  • A string and a number: an EarthEngine asset id and version,

  • A number or ee.Array: creates a constant image,

  • A list: creates an image out of each list element and combines them into a single image,

  • An ee.Image: returns the argument,

  • Nothing: results in an empty transparent image.

That's why you get invalid data type error, since a local file isn't a valid input.

Solution: upload your file to GEE and then call the asset.

You can either upload the raster to Earth Engine with command line tools or use the Asset manager, then you can access to the file with the asset ID or path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.