Skip to content
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

Clipping the output shorelines #501

Open
evecchi opened this issue Jun 13, 2024 · 2 comments
Open

Clipping the output shorelines #501

evecchi opened this issue Jun 13, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@evecchi
Copy link

evecchi commented Jun 13, 2024

Hi @kvos,

I'm writing you to ask a question about the output geojson and pkl files (SITENAME_output.geojson/pkl).
I'm trying to add a new section of the script where the extracted shorelines are clipped basing on a given polygon, to clean possible incorrect points which are not related to the shoreline.
Thus, I'm using the output geojson, clipping it using a polygon shapefile and I want to load the clipped geojson back to your script.
For the following steps, I would need the clipped output to be read again as a dictionary and as a pkl file, right?
But the exported output.geojson seems to have only the following keys: (['type', 'crs', 'features']), and to be not complete having: (['dates', 'shorelines', 'filename', 'cloud_cover', 'geoaccuracy', 'idx', 'MNDWI_threshold', 'satname']).

What do you suggest?

Thank you in advance

Enrica

@kvos kvos self-assigned this Jun 13, 2024
@kvos kvos added the enhancement New feature or request label Jun 13, 2024
@kvos
Copy link
Owner

kvos commented Jun 13, 2024

hi @evecchi , I remember there was another issue where someone was loading the geojson in QGIS/Arc, cleaning it up and wanted to continue with the cleaned geometry. I'll flag it as an enhacement. I would suggest that you add a section where you do the follow:

  • read the output.pkl file and your cleaned .geojson shorelines (named by date?) with gdf = gpd.read_file(filename_geojson)
  • then in the output dictionary for each date replace the 'shorelines' numpy array with the coordinates of your geojson np.array(gdf.iloc[0].geometry.coords). Make sure that the index is matching with the right date. Then you can save output.pkl again and continue with the notebook.

While writing this I'm realising that it may be much easier to bring in your polygon shapefile with geopandas and then clip all the shoreline points based on the polygon. Have a go at either option and let me know if you need help, should be feasible. Also make sure that the coordinate system is not altered when going in and out of QGIS/Arc.

@evecchi
Copy link
Author

evecchi commented Jun 13, 2024

Hi @kvos,

thank you for the advice!
The first method is working!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants