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

CRS mismatch error when trying to map shorelines with manually-uploaded transects #247

Closed
FlorisCalkoen opened this issue May 6, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@FlorisCalkoen
Copy link

FlorisCalkoen commented May 6, 2024

ping #openjournals/joss-reviews#6683

I have manually uploaded transects for my area of interest in 4326 - please see output below, but I get a CRS mismatch error, when computing the shoreline distances. Can you reproduce this? I'm looking at Terschelling in The Netherlands (see screenshot below).

In [5]: transects = gpd.read_file("https://coclico.blob.core.windows.net/public/gcts-terschelling.geojson")

In [6]: transects.crs
Out[6]:
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World.
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984 ensemble
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
CRS mismatch between CRS of the passed geometries and 'crs'. Use 'GeoDataFrame.set_crs(crs, allow_override=True)' to overwrite CRS or 'GeoDataFrame.to_crs(crs)' to reproject geometries.

Additional Information
Traceback (most recent call last): File "/Users/calkoen/mambaforge/envs/coastseg/lib/python3.10/site-packages/coastseg/map_UI.py", line 905, in extract_shorelines_button_clicked self.coastseg_map.extract_all_shorelines() File "/Users/calkoen/mambaforge/envs/coastseg/lib/python3.10/site-packages/coastseg/coastseg_map.py", line 1858, in extract_all_shorelines self.compute_transects(self.transects.gdf, self.get_settings(), selected_roi_ids) File "/Users/calkoen/mambaforge/envs/coastseg/lib/python3.10/site-packages/coastseg/coastseg_map.py", line 1992, in compute_transects self.save_transect_timeseries(session_path,self.rois.get_extracted_shoreline(roi_id),roi_id) File "/Users/calkoen/mambaforge/envs/coastseg/lib/python3.10/site-packages/coastseg/coastseg_map.py", line 2098, in save_transect_timeseries common.save_transects( File "/Users/calkoen/mambaforge/envs/coastseg/lib/python3.10/site-packages/coastseg/common.py", line 1912, in save_transects merged_timeseries_df,timeseries_df = add_lat_lon_to_timeseries(merged_timeseries_df, transects_gdf.to_crs('epsg:4326'),cross_distance_df, File "/Users/calkoen/mambaforge/envs/coastseg/lib/python3.10/site-packages/coastseg/common.py", line 1787, in add_lat_lon_to_timeseries new_gdf_shorelines_wgs84=convert_points_to_linestrings(cross_shore_pts, group_col='date', output_crs='epsg:4326') File "/Users/calkoen/mambaforge/envs/coastseg/lib/python3.10/site-packages/coastseg/common.py", line 1998, in convert_points_to_linestrings linestrings_gdf = gpd.GeoDataFrame(linestrings, columns=['geometry'], crs=output_crs) File "/Users/calkoen/mambaforge/envs/coastseg/lib/python3.10/site-packages/geopandas/geodataframe.py", line 152, in __init__ raise ValueError(crs_mismatch_error) ValueError: CRS mismatch between CRS of the passed geometries and 'crs'. Use 'GeoDataFrame.set_crs(crs, allow_override=True)' to overwrite CRS or 'GeoDataFrame.to_crs(crs)' to reproject geometries.

image

@FlorisCalkoen FlorisCalkoen changed the title CRS mismatch error when trying to map shorelines with mannualy-uploaded transects CRS mismatch error when trying to map shorelines with manually-uploaded transects May 6, 2024
@2320sharon 2320sharon added the bug Something isn't working label May 6, 2024
@2320sharon 2320sharon self-assigned this May 6, 2024
@FlorisCalkoen
Copy link
Author

@2320sharon, if you want to reproduce, you should be able to access my transect data like this:

import geopandas as gpd

transects = gpd.read_file("https://coclico.blob.core.windows.net/public/gcts-terschelling.geojson")

transects.shape 
# (2220, 19)

print(list(transects.columns))
# ['tr_name', 'lon', 'lat', 'bearing', 'coastline_is_closed', 'coastline_length', 'utm_crs', 'bbox', 'quadkey', 'bounding_quadkey', 'isoCountryCodeAlpha2', 'admin_level_1_name', 'isoSubCountryCode', 'admin_level_2_name', 'coastline_name', 'coastline_id', 'segment_id', 'transect_id', 'geometry']

Note that I have now included all transect attribiutes that we have in this collection, but the error above also happened when I was just including the tr_name and geometry in the geojson.

@2320sharon
Copy link
Collaborator

Hi @FlorisCalkoen,

Sorry for the delay getting back to you. I was having some difficulty reproducing the error you showed here, until I realized I was running CoastSeg 1.2.2 instead of 1.2.4 . I'm currently working on understanding this error and fixing it. Thanks for finding this

2320sharon added a commit that referenced this issue May 7, 2024
@2320sharon 2320sharon reopened this May 8, 2024
@2320sharon
Copy link
Collaborator

@FlorisCalkoen

Good news! I was able to replicate your bug and its now fixed in CoastSeg 1.2.5 . Once you've updated your coastseg environment this issue should be fixed

@FlorisCalkoen
Copy link
Author

@2320sharon, many thanks for the fix, as I can confirm that with CoastSeg 1.2.5 I can map SDS with my own transects.

@2320sharon
Copy link
Collaborator

@FlorisCalkoen that's great to hear! I'm going to close this issue now that it has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants