TypeError: Image data of dtype object cannot be converted to float #1978
-
The main functionality of the script is to extract GeoJSON data, load it into Earth Engine, retrieve Sentinel-2 imagery, calculate the mean NDVI, and visualize the NDVI for each GeoJSON feature. My GeoJSON file.
My Script.
the error this script is producing.
What I have tried. I added a print statement to print out the ndvi_array just before I attempted to plot it. Print out the ndvi_array {'type': 'Image', 'bands': [{'id': 'NDVI', 'data_type': {'type': 'PixelType', 'precision': 'float', 'min': -1, 'max': 1}, 'dimensions': [62, 53], 'origin': [8697, 7265], 'crs': 'EPSG:32643', 'crs_transform': [10, 0, 300000, 0, -10, 3600000]}], 'properties': {'system:time_start': 1713074411607, 'system:footprint': {'type': 'Polygon', 'coordinates': [[[73.806423917413, 31.876305483265007], [73.805073425174, 31.875375605313], [73.805913291872, 31.871866128353002], [73.811334036291, 31.871658562207003], [73.811508715153, 31.872104159734995], [73.811180479825, 31.872252786674], [73.811554983258, 31.873010438666004], [73.810586370528, 31.873344418569005], [73.809291869402, 31.873843820189997], [73.808021843433, 31.874272893423], [73.807903490961, 31.874086971424], [73.80733653903, 31.87418007483], [73.807264119387, 31.874479599523003], [73.806831277907, 31.874537112708], [73.806423917413, 31.876305483265007]]]}}} The printed output shows the structure of the ndvi_array, which is a dictionary representing an Earth Engine Image object. This indicates that the conversion from Earth Engine Image to NumPy array is not working as expected. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you want others to help you, try to provide a minimal script that can reproduce the issue. Don't use absolute file paths. No one can access your local files. Avoid providing a long script with all kinds of for loops, making it very difficult to debug. |
Beta Was this translation helpful? Give feedback.
If you want others to help you, try to provide a minimal script that can reproduce the issue. Don't use absolute file paths. No one can access your local files. Avoid providing a long script with all kinds of for loops, making it very difficult to debug.