ronnyhdez / reclaimed_sites_ab

https://ronnyhdez.github.io/reclaimed_sites_ab/
0 stars 0 forks source link

Test filtering latency within the intersections procedure or directly as an asset #66

Closed ronnyhdez closed 5 months ago

ronnyhdez commented 5 months ago

It looks like when running the code with the buffers, intersection detections, and so on, the filtering step takes too long. Probably saving the intermediate object as an asset (which takes time) can save time later for the filtering processing.

ronnyhdez commented 5 months ago

It works much better. The filter runs immediately.

For this reason, all the buffers and intersecting variables should be in one step as ref #65

ronnyhdez commented 5 months ago

This was part of the code for the test:

## Mapping the abandoned wells intersecting waterbodies.

The filter takes too long. Probably it will be faster if I export the object as an asset.
Probably it's because it performs or re-process all the queries.

# First test on a filter
# Gonna do it on a variable already in the asset
asset_id = 'projects/ee-ronnyale/assets/selected_polygons'

abandoned_wells = ee.FeatureCollection(asset_id)

# The filter
reclaimed_filter = ee.Filter.eq("rclmtn_s", "reclaimed")
reclaimed = abandoned_wells.filter(reclaimed_filter)
sample = reclaimed.limit(10).getInfo()
print(json.dumps(sample, indent=2))

When applied to an asset directly, the filter is super fast. 

I'm going to save the asset with the new columns:

# # Export the result as an asset for future use
# export_asset_id = 'projects/ee-ronnyale/assets/intersecting_wells_waterbodies'
# export_task = ee.batch.Export.table.toAsset(
#     collection=wells_with_intersections,
#     description='export_intersecting_wells_with_waterbodies',
#     assetId=export_asset_id
# )
# export_task.start()

And this one to map the intersecting abandoned wells polygons in the water bodies:

intersects_asset_id = 'projects/ee-ronnyale/assets/intersecting_wells_waterbodies'
intersects = ee.FeatureCollection(intersects_asset_id)

intersecting_filter = ee.Filter.eq("intersects_buffer", 1)
intersecting_water = intersects.filter(intersecting_filter)
sample = intersecting_water.limit(10).getInfo()
print(json.dumps(sample, indent=2))

# Plot abandoned wells that intersect waterbodies
wells_intersecting_map = geemap.Map(center=[53.516, -113.498], zoom = 5)
wells_intersecting_map.addLayer(intersecting_water, {}, 'wells intersecting water')
wells_intersecting_map

image

ronnyhdez commented 5 months ago

Ref #67