I have a featureCollection of pixels (called "Pixel_values")from using sampleRegions and a feature collection of lineStrings (called "Hydro"), some of which intersect the pixels. I want to add a column/property to "Pixel_values" that returns true or false for if a pixel intersects with "Hydro". Every time I've succesfully exported a csv, every pixel returns a "FALSE" value.
Here is the code for generating "Pixel_values":
// REGION
var region = ee.FeatureCollection([
ee.Feature(geometry2, {id: 1, Dam: 'no'}),
ee.Feature(geometry3, {id: 2, Dam: 'yes'}),
ee.Feature(geometry4, {id: 3, Dam: 'no'}),
ee.Feature(geometry5, {id: 4, Dam: 'yes'}),
ee.Feature(geometry6, {id: 5, Dam: 'yes'})
]);
// NAIP
var NAIP_add_NDVI_NDWI = function(image) {
var ndvi = image.normalizedDifference(['N','R']).rename('NDVI_N');
var ndwi = image.normalizedDifference(['G', 'N']).rename('NDWI_N');
return image.addBands(ndvi).addBands(ndwi)
};
var NAIP_Filter = NAIP.filterDate(startDate,endDate).filterBounds(region);
// apply ndvi to NAIP collection
var NAIP_Indices = NAIP_Filter.map(NAIP_add_NDVI_NDWI);
var NAIP_NDVI_NDWI = NAIP_Indices.select('NDVI_N')
var NAIP_IndicesClipped = NAIP_NDVI_NDWI.mean().clip(region);
// Generate pixel values of NDVI
var Pixel_values = NAIP_IndicesClipped.sampleRegions({
collection: region, // area to take pixel values from
properties: ['id','Dam'], // what properties to retain from area
scale: 6 // how many pixels .6 is highest resolution
});
I then used the intersect function, and tried with multiple types of data to represent the hydrology that intersects the pixels. First, I imported a shapefile of a featureCollection of lineString. Then, I drew a line geometry that intersects the points. It didn't work for either.
// Define a function to check if a feature overlaps with any feature in the river collection
var checkIntersection = function(feature) {
var Intersect_check = feature
.geometry()
.intersects(Hydro.geometry(), ee.ErrorMargin(1));
return feature.set('Intersects', Intersect_check);
};
// Map the checkIntersection function over the region feature collection
var Intersect_practice = Pixel_values.map(checkIntersection);
// // Export the data to a CSV file
Export.table.toDrive({
description: "Add_Intersect_Feature_Test6",
collection: regionWithOverlap,
fileFormat: "CSV",
folder: "Pixel_test",
fileNamePrefix: "Add_Intersect_Feature_Test6"
});
Finally, I tried to run a union on "Hydro" to make it a single feature, but that didn't work.
Here is the link to the Hydrology data (Streams Chapter 93 Designated Use) used: https://www.pasda.psu.edu/uci/SearchResults.aspx?Keyword=streams