-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: merge shoreline segments into single merged shoreline #179
Comments
I agree the fastest way to get this out would be a script. I can investigate how to do a few things
I think this issue is do-able as a V1. |
Today I took some time to scope out this issue. Below I've outlined the prerequisites to merge ROIs, possible scenarios that could be encountered when combining roi's, as well as some questions I've come across while scoping out this issue. I've also included some demo code that introduces how we might merge the extracted shorelines together. I plan on working on this issue more during the week. Prerequisites to Merge ROIs
Possible ScenariosEach of these scenarios outline possible inputs that could influence the way the roi's are merged.
Files to be Merged
Questions
Sample CodeThe following sample code outlines how two extracted Shoreline Geo Json files can be merged together. Please note that we might not take this approach as we are still brainstorming possible solutions.
|
Nope. |
@dbuscombe-usgs We could average the the points across the shorelines. Basically if any of the shoreline points don't perfectly overlap for the same time date we create a new averaged shoreline out of the shorelines. Then use this new shoreline to intersect with the transects. If you have any ideas let me know. Also I realized that the approach of averaging the intersection values for shoreline points that intersect with transects for the same satellite and date, won't work because the shoreline points are derived from the shoreline vectors. Therefore after merge the shoreline vectors would need to recompute the shoreline transect intersections for any new merged shorelines we created. |
So I did a bit more thinking on this idea. Steps
Example ROIsExample Merged Shoreline |
Sorry for late response - yes, I like the last idea you had about averaging those overlapped shorelines, then appending that averaged segment to the rest of the shoreline from the two ROIs. Thanks for presenting these options! |
All good, I'll give that approach a shot and see how it performs. Also I'm pretty sure the approach will struggle with back barrier shorelines, so expect some wonky results for back barrier shorelines or regions where there are discontinuous shorelines. |
Agree. This merge operation will be tricky for backbarrier shoreline workflows, which are tricky in general because inner shorelines tend to be far more complicated in 2d planform shape that outer coast ones. So much so that users should probably be encouraged to use coastseg only for the outer shorelines, where possible |
I've been working on the script to merge extracted Shoreline sessions together. I want to leave a quick update while I keep working on it today. I've found that the method we use of averaging the points that make up each of the extracted shorelines Works moderately well when the shorelines are the same shape as you can see an example one. However if the shorelines are vastly different shapes as seen an example 2 the method falls apart, which means the user will need to filter out shorelines before they use this script. I've found that not all the extracted shorelines are continuous single line strings. As you can see an example two which has multiline strings this complicates the averaging process as each line string in each multiline string has to be averaged together and depending on the orientation of each line string this can result in vastly different shapes. To improve this method at some point we should probably take an account the distance each line string is from each other and find a way to average the line strings that are closest together first then the line strings that aren't. I think if we implement this it would improve the results. Example 1Example 2Code
Plotting Code
|
I've made some headway on the merge sessions notebook for CoastSeg:
The purpose of the merge sessions notebook is to combine all the shorelines, ROIs, and transect data into a unified archive. This compiled data is not intended to be loaded into CoastSeg due to the complex dependencies and data references that would be compromised. To accommodate loading merged sessions into Coastseg, would necessitate extensive modifications to both CoastSeg and CoastSat. Such an overhaul would require in-depth consultation with users and a thorough review of all processes within both systems. I think our resources are better spent getting the Planet API working and refining CoastSeg’s internal architecture. This approach will lay a stronger foundation, potentially simplifying the future incorporation of merged sessions. |
test_case1_same_rois.zip I made sample data to test merge_session.py with |
merge_sessions.py Script Usage InstructionsGetting StartedTo utilize the script in the development branch of CoastSeg, follow these instructions. Step 1: Switch to the Development BranchBegin by switching to the specified development branch: git switch issue/179 Step 2: Environment ActivationActivate your conda activate coastseg Step 3: Install the CoastSeg PackageInstall the CoastSeg package in editable mode. This will synchronize the CoastSeg version with the current branch's code. pip install -e . Note: The Running the ScriptPreparing the EnvironmentNavigate to the scripts directory with the coastseg directory and open the cd scripts
code merge_sessions.py Executing the ScriptExample 1: Merging Two Sessions into a Single Merged SessionConsider merging two sessions with extracted shorelines into a single session.
To execute, separate each session location with a space (use double quotes on Windows): python merge_sessions.py -i "C:\development\doodleverse\coastseg\CoastSeg\test_data\test_case4_overlapping\ID_gac6_datetime10-30-23__01_44_50" "C:\development\doodleverse\coastseg\CoastSeg\test_data\test_case4_overlapping\ID_gac1_datetime10-30-23__01_44_50" -s "merged_sessions" -n "merged_session1" Example 2: Customizing ParametersMerge the same sessions but modify the python merge_sessions.py -i "C:\development\doodleverse\coastseg\CoastSeg\test_data\test_case4_overlapping\ID_gac6_datetime10-30-23__01_44_50" "C:\development\doodleverse\coastseg\CoastSeg\test_data\test_case4_overlapping\ID_gac1_datetime10-30-23__01_44_50" -s "merged_sessions" -n "merged_session1" -pm 0.3 -mp 2 Please follow these steps carefully to ensure successful execution of the script in the development branch of CoastSeg. |
Often, shorelines from different ROIs may have the same timestamp, i.e. a second shoreline extracted from an adjacent ROI image with the same timestamp.
So, we need a way to take the raw shoreline data and merged based on date. pandas/geopandas
merge
command seems to do this, e.g.https://stackoverflow.com/questions/48231758/merge-pandas-dataframes-based-on-date
I think this might be best as a stand-alone script, at least initially while we test the workflow
The text was updated successfully, but these errors were encountered: