I would like to collect pixel level value of country from the featureCollection "USDOS/LSIB_SIMPLE/2017". I use reduceToImage function to reduce featureCollection to ImageCollection and use getRegion to get pixel value of country.

# Get country boundary
country = ee.FeatureCollection("USDOS/LSIB_SIMPLE/2017")
country_img = country.reduceToImage(['abbreviati'], ee.Reducer.first())

# Define geographic domain
world_geometry = ee.Geometry.Polygon([
        -180, 90,
        0, 90, 
        180, 90, 
        180, -90, 
        0, -90,
        -180, -90], None, False) 
#Get pixel values
img_get_region = ee.ImageCollection(country_img).getRegion(world_geometry, scale = 30000).getInfo()
# Convert to dataframe 
img_get_region_df = pd.DataFrame(img_get_region[1:len(img_get_region)], columns = img_get_region[0]).drop(['id', 'time'], axis = 1)

However, I get the error "EEException: Collection.reduceToImage: Property 'abbreviati' not a numeric type." It seems that reduceToImage only accepts numeric features. So how can I collect string feature in this function?

1 Answer 1


In Earth Engine, image pixel values can be numbers, or arrays of numbers. They cannot be strings.

You will have to add a numeric ID property of some sort, and convert that to strings after the getRegion().

  • How can I map from string to number in google earth engine? Presumbly I have a dictionary to map from string to id number of country. Thank you very much for your support.
    – Da Hoang
    Jan 18, 2023 at 16:53
  • @DaHoang Once you have that dictionary you can map over the collection to add a numeric property based on the string property. Here's a previous answer I wrote about how to do that.
    – Kevin Reid
    Jan 18, 2023 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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