I'm using Google Earth Engine with the Python API. I have calculated the NDVI value over an area, set a threshold and the result is a layer where black areas exceed my NDVI threshold (don't pay attention to the red and blue dots, they are not important in this issue)

enter image description here

Now, I want to automatically identify these black areas (the ones that exceed a given extension) and save their position in order to get a list of the (probably) irrigated camps in this ROI.

How could I do this?


I believe you are looking for vectorization: a transformation of the raster image into vector areas.

You can probably use the rasterio.features.shapes() function from the Python's rasterio package, which gives out GeoJSON-like coordinates of contiguous areas of the same value from the raster, and then potentially use shapely to convert the areas to centroids to have simple point coordinates for each camp.

Given that your example above contains a considerable amount of noise (very small black areas), you might want to do some binary opening or closing to remove it, for example using scipy.ndimage.

  • Thank you for your response, I will try to remove the noise and then proceed to the vectorization, hoping that all will work properly! Sep 24 '19 at 7:31

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.