Closed ronnyhdez closed 4 months ago
Another guess is that some features are returning no values in geometries after the negative buffer, such as this cases:
This is not whats happening because they were filtered out by dates in the firs filters
Also, checking what's happening in GEE console, when I print the original sampled feature collection, in geometries I have:
In the dilated feature collection:
The coordinates list have 2 elements
But with the python API this doesn't seem to happen.
Using just one test case, I got the following:
var smallPolygon = ee.Geometry.Polygon([
[
[-122.263, 37.872],
[-122.263, 37.873],
[-122.262, 37.873],
[-122.262, 37.872],
[-122.263, 37.872]
]
]);
// Create a feature collection from this polygon
var featureCollection = ee.FeatureCollection([ee.Feature(smallPolygon)]);
var applyInwardBuffer = function(feature) {
var bufferedFeature = feature.buffer(-30, 1);
return bufferedFeature;
};
var bufferedCollection = featureCollection.map(applyInwardBuffer);
print(bufferedCollection);
Map.addLayer(featureCollection, {color: 'blue'}, 'Original FeatureCollection');
Map.addLayer(bufferedCollection, {color: 'red'}, 'Buffered FeatureCollection');
var check = bufferedCollection.geometry().coordinates().size()
print(check)
If I expand the negative buffer to -300, I will obtain the following:
So, probably to solve the error of empty geometries, I can use the size to filter out those.
In the notebook, I use the following to flag which polygons ended up with no coordinates after the negative buffer:
def check_empty_coordinates(feature):
coordinates = feature.geometry().coordinates()
is_empty = coordinates.size().eq(0)
return feature.set('empty_buffer', is_empty)
check_empty_dilated = dilated_abandoned_wells.map(check_empty_coordinates)
results = check_empty_dilated.limit(2).getInfo()
print(json.dumps(results, indent = 2))
After that, I was able to filter and check a couple of those:
run_filter = check_empty_dilated.filter(ee.Filter.eq('empty_buffer', 1))
# total = run_filter.size()
# print(total)
results = run_filter.limit(2).getInfo()
print(json.dumps(results, indent = 2))
That one worked!
Finally, with those filtering steps to avoid empty geometries, I can create the asset in GEE
Well, I had to join the v2 asset with the pixel count and it works:
// Check newly created merged asset to compare with v2
var v2 = ee.FeatureCollection("projects/ee-ronnyale/assets/intersecting_wells_flags_v2");
var merged = ee.FeatureCollection("projects/ee-ronnyale/assets/intersecting_wells_flags_v3_with_pixel_count_join");
Map.centerObject(v2, 10);
Map.addLayer(v2, {color: 'blue'}, 'Original FeatureCollection');
Map.addLayer(merged, {color: 'red'}, 'Buffered FeatureCollection');
Ref #117
Error: Unable to export features with empty geometry. (Error code: 3)
Something happens with the negative buffer that I can't establish the new geometry.
Nonetheless, when checking some characteristics, I get basically the same results from the original asset and the negative buffer one: