0

I have run an NDWI index for an Image collection and thres holded the results, which I want to import as individual FeatureCollections (shapefiles).

My code is of course longer, but teh most importan lines are below. The problem with my current code is that it exports all the results from all the thresholded images as a single shapefile. >When visualizing that shapefiles on QGIS, all polygons are drawn simoultaneously on top of eachother. What am I missing here to export them individually?

// Apply function to each single image in the bandThresh ImageCollection
var vectors = bandThresh.map(reduceToVectors);
// Combine all geometries into a single FeatureCollection
vectors = vectors.flatten();

// Export the FeatureCollection to Google Drive
Export.table.toDrive({
  collection: vectors,
  description: 'bandThresh_vector', 
  folder: 'NEWFOLDER', 
  fileFormat: 'SHP' 
});  

1 Answer 1

0

In below code block you are converting each raster into a vector. That means the vectors variable contains a collections of collections.

// Apply function to each single image in the bandThresh ImageCollection
var vectors = bandThresh.map(reduceToVectors);

But in this line vectors = vectors.flatten(); you are flatten the collections of collections. That means collections from each image will be a single feature now.

To export each image as a shape file you can map over the vectors and add export block inside it, instead of flattening it. Furthermore, you can share your code link for better understanding of us.

1
  • I am a bit of a GEE newbie, so I am not sure about your suggestion without a code. Below is the link to my preliminary code in case you can help with additional coding to solve my issue. You will see that there are some commented bits and pieces that I have not fully incorporated so far, but if you run the code as is, you will get an idea. code.earthengine.google.com/92f20a93f08a922dbf1245cbb331dc90 Commented Oct 17, 2023 at 15:02

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.