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

Paste Features As -> New Vector Layer creates a vector layer with invalid CRS #60846

Open
2 tasks done
agiudiceandrea opened this issue Mar 4, 2025 · 7 comments · May be fixed by #60852
Open
2 tasks done

Paste Features As -> New Vector Layer creates a vector layer with invalid CRS #60846

agiudiceandrea opened this issue Mar 4, 2025 · 7 comments · May be fixed by #60852
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! GUI/UX Related to QGIS application GUI or User Experience

Comments

@agiudiceandrea
Copy link
Member

agiudiceandrea commented Mar 4, 2025

What is the bug or the crash?

Using the Paste Features As -> New Vector Layer functionality, if the pasted features doesn't have CRS information, then the new vector layer's CRS is unknown / invalid even properly setting the CRS in the dialog window.

Steps to reproduce the issue

  1. copy the following text:
wkt_geom fid
Polygon ((602049.70009776263032109 4531463.99115845467895269, 621551.28105399641208351 4540522.10253156814724207, 619526.52674706501420587 4524643.76612458005547523, 604607.28448546538129449 4521127.08759148884564638, 602049.70009776263032109 4531463.99115845467895269)) 1
  1. in QGIS, select the Edit -> Paste Features As -> New Vector Layer menu
  2. in the "Save Vector Layer as..." dialog window set the format e.g. GeoPackage or ESRI Shapefile, set the path / filename of the output vector layer file, set the CRS as ESPG:32633, leave other options as default, then press the OK button.
  3. see the new vector layer created having no CRS information.

Versions

QGIS version3.40.4-Bratislava
QGIS code revision4dd7d7e969
 
Libraries
Qt version5.15.13
Python version3.12.9
GDAL version3.10.2
PROJ version9.5.1
EPSG Registry database versionv11.022 (2024-11-05)
GEOS version3.13.0-CAPI-1.19.0
SQLite version3.46.1
PDAL version2.8.3
PostgreSQL client versionunknown
SpatiaLite version5.1.0
QWT version6.3.0
QScintilla2 version2.14.1
OS versionWindows 10 Version 1903
 
Active Python plugins
db_manager0.1.20
grassprovider2.12.99
MetaSearch0.3.6
processing2.12.99

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

@agiudiceandrea agiudiceandrea added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Mar 4, 2025
@agiudiceandrea agiudiceandrea self-assigned this Mar 4, 2025
@mblesius
Copy link

mblesius commented Mar 4, 2025

I can't reproduce the issue with my "working" profile with QGIS 3.40.4, but strangely it occurs with a new profile

@agiudiceandrea
Copy link
Member Author

agiudiceandrea commented Mar 4, 2025

@mblesius, thanks for testing!
If, using your "working" profile, the new layer shows a valid CRS assigned to it when it is subsequently loaded in QGIS after the creation, then that is due to the fact that you have set an option different than "Leave as an unknown (take no action)" - which is the default - in Settings -> Options -> CRS and Transforms -> CRS Handling -> CRS for Layers. Could you check, please? How are set such options? What is the CRS of the layer as displayed in QGIS? May please check the actual CRS of the layer using the "Vector information" GDAL processing algorithm with the "Enable listing of all layers in the dataset" option set?

@mblesius
Copy link

mblesius commented Mar 4, 2025

Yes, you're right. I've set this option to use the default layer CRS which is EPSG:25832 in my case. I didn't notice the warning message at first. Thus, I confused UTM Zone 33 for Zone 32.

@uclaros
Copy link
Contributor

uclaros commented Mar 4, 2025

Same with Layer > Save As... for a layer that has no CRS set.
The CRS selector in QgsVectorLayerSaveAsDialog is used to reproject the data, not to be assigned to the data.

This looks like expected behavior, since the transformation from invalid crs fails, though we probably could communicate this better to the user.

@agiudiceandrea
Copy link
Member Author

agiudiceandrea commented Mar 4, 2025

@uclaros, looking at the code, it seems to me that such case (invalid source layer's CRS) was not taken in consideration, since in such case an invalid Coordinate Transorm is unawares created (while the invalid destination layer's CRS case was considered, and in such case the Coordinate Transorm is not created), so I think such behaviour is not by design. I'll propose a PR to fix it: it is reasonable to me that, in such case, the chosen CRS should be assigned to the new vector layer.
I think the CRS selector in QgsVectorLayerSaveAsDialog is used to set the CRS of the output layer and to reproject the data if needed.
The "Vector General - Reproject layer" processing algorithm creates an output layer with a chosen CRS even if the input layer's CRS is invalid (without obviously performing any reprojection).

@uclaros
Copy link
Contributor

uclaros commented Mar 4, 2025

I think the CRS selector in QgsVectorLayerSaveAsDialog is used to set the CRS of the output layer and to reproject the data if needed.

Both the code and the documentation suggests that this CRS is for reprojection, not assignment. I think it's more appropriate to disable the crs selector and show a tooltip if the source crs is not valid. Let the user fix his layer, then try again.

The "Vector General - Reproject layer" processing algorithm creates an output layer with a chosen CRS even if the input layer's CRS is invalid (without obviously performing any reprojection).

I'd consider this a bug as users would expect the coords to be reprojected as the algorithm name hints, not just transferred unchanged!

@agiudiceandrea
Copy link
Member Author

@uclaros, in the meantime I've found another glitch in the Paste Features As functionality:

  1. new project with the World Map layer
  2. copy the text
wkt_geom fid
Polygon ((602049.70009776263032109 4531463.99115845467895269, 621551.28105399641208351 4540522.10253156814724207, 619526.52674706501420587 4524643.76612458005547523, 604607.28448546538129449 4521127.08759148884564638, 602049.70009776263032109 4531463.99115845467895269)) 1
  1. Edit -> Paste Features As -> New Vector Layer -> the dialog window shows CRS Invalid, which is correct. Close the dialog window
  2. select a feature from the World Map layer and then Edit -> Copy Features
  3. Edit -> Paste Features As -> New Vector Layer -> the dialog window shows CRS EPSG:4326 - WGS 84, which is correct. Close the dialog window
  4. copy again the text from point 2.
  5. Edit -> Paste Features As -> New Vector Layer -> the dialog window shows CRS EPSG:4326 - WGS 84, which is wrong

@agiudiceandrea agiudiceandrea removed their assignment Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! GUI/UX Related to QGIS application GUI or User Experience
Projects
None yet
3 participants