qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.67k stars 3.02k forks source link

Exported layer (as shp) with Values set by Cascading Value Relations have fields converted to string fields (254) #45381

Open Mikester-Calgary opened 3 years ago

Mikester-Calgary commented 3 years ago

What is the bug or the crash?

I have cascading Value Relations tables for data entry and they work fine. Except I need to "Export" the layer in order to keep the displayed values instead of the key values. Except when I check the boxes that I want to hold the selected values for it changed the data type to string with a length of 254 no matter what the field parameters were set for initially.

Steps to reproduce the issue

public_lands_disposition_NAD83_10TM.zip PLA Disp Activities.csv PLA Disp Purpose.csv PLA Disp Types.csv

Public Lands Dispositon Data Entry Style.zip Test_Output.zip

1: Add public lands shp to project. 2: Style it with the Public Lands style file. qml 3: Notice the field parameters in this layer under Properties ==>Fields. 4: Add a polygon and fill in the drop down fields from the available menu items. 5: Save the shps created. 6: Export the layer to a new shp file retaining the selected values by checking "Replace with displayed values" where appropriate. 7: Notice that all those checked fields in the new file are 254 character strings.

ANY field checked for "Replace with displayed values" gets changed to a 254 character string no matter the incoming field settings. This can be very damaging when the field parameters are important as they very often are!

Versions

QGIS version 3.20.3-Odense QGIS code revision 495fbaec Qt version 5.15.2 Python version 3.9.5 GDAL/OGR version 3.3.1 PROJ version 8.1.1 EPSG Registry database version v10.028 (2021-07-07) GEOS version 3.9.1-CAPI-1.14.2 SQLite version 3.35.2 PDAL version 2.3.0 PostgreSQL client version 13.0 SpatiaLite version 5.0.1 QWT version 6.1.3 QScintilla2 version 2.11.5 OS version Windows 10 Version 2009

Active Python plugins DataPlotly db-style-manager flight_planner getools ImportPhotos kmltools LAStools Mergin mmqgis processing_wbt profiletool qgis2web QuickPrint SRTM-Downloader Three_D_Change_Detection-master track_profile_2_web turbo_volume volume_calculation_tool db_manager MetaSearch processing

Supported QGIS version

New profile

Additional context

I have also posted this on StackExchange with no luck so far.

gioman commented 3 years ago

gets changed to a 254 character string

@Mikester-Calgary that is a limit of the shapefile format, use Geopackage instead.

Mikester-Calgary commented 3 years ago

Thanks but that is not the issue. It changes everything to a 254 character string. 10 character strings, Integers, real numbers etc. It has nothing to do with needing more than 254 characters in the string! It has to do with completely reformatting the parameters of the field for no reason. (Well I guess the bug is the reason.)

gioman commented 3 years ago

[Test_Output.zip](https://github.com/qgis/QGIS/f

@Mikester-Calgary this link is broken

Mikester-Calgary commented 3 years ago

Test_Output.zip

gioman commented 3 years ago

@Mikester-Calgary despite having loaded all the layers when loading the style I still get

2021-10-04T16:29:36     WARNING    Missing layer form dependency : layer 'Disposition' requires layer 'PLA Disp Types' to be loaded but 'PLA Disp Types' could not be found, please load it manually if possible.
2021-10-04T16:29:36     WARNING    Missing layer form dependency : layer 'Disposition' requires layer 'PLA Disp Purpose' to be loaded but 'PLA Disp Purpose' could not be found, please load it manually if possible.
2021-10-04T16:29:36     WARNING    Missing layer form dependency : layer 'Disposition' requires layer 'PLA Disp Activities' to be loaded but 'PLA Disp Activities' could not be found, please load it manually if possible.

If you can load a QGIS project (together with all the necessary files and styles already loaded) we would appreciate.

Mikester-Calgary commented 3 years ago

Those are the csv files that are attached.

Mikester-Calgary commented 3 years ago

AER Entry.zip

gioman commented 3 years ago

Those are the csv files that are attached.

@Mikester-Calgary yes, and as I said I still get those message when applying the style, this is why I asked the project.

Mikester-Calgary commented 3 years ago

It’s in there.

From: Giovanni Manghi @.> Sent: October 4, 2021 9:36 AM To: qgis/QGIS @.> Cc: Mikester-Calgary @.>; Mention @.> Subject: Re: [qgis/QGIS] Exported layer with Values set by Cascading Value Relations tables are converted to strings (#45381)

Those are the csv files that are attached.

@Mikester-Calgary https://github.com/Mikester-Calgary yes, and as I said I still get those message when applying the style, this is why I asked the project.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/qgis/QGIS/issues/45381#issuecomment-933605699 , or unsubscribe https://github.com/notifications/unsubscribe-auth/APO4JMXDKBZSCZFBMIE27ATUFHCUZANCNFSM5FJRFWHQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub . https://github.com/notifications/beacon/APO4JMSXHTMK3QEGVAOUMUDUFHCUZA5CNFSM5FJRFWH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOG6S3CQY.gif

Mikester-Calgary commented 3 years ago

The project is in AER Entry.zip above.

gioman commented 3 years ago

AER Entry.zip

@Mikester-Calgary

Screenshot 2021-10-04 163646

Mikester-Calgary commented 3 years ago

AER Entry.zip

csv files are local in this one.

gioman commented 3 years ago

The project is in AER Entry.zip above.

@Mikester-Calgary the project you sent seems to point to database tables, if you can it would help if you can attach a self contained project, with all the data/layers/styles needed, that opens on any machine without errors.

gioman commented 3 years ago

6: Export the layer to a new shp file retaining the selected values by checking "Replace with displayed values" where appropriate. 7: Notice that all those checked fields in the new file are 254 character strings.

@Mikester-Calgary I was able to fix the project you sent and test your steps, and as I suspected is ok if you save to gpkg, and the fields length changes to 254 if you save to shp.

Mikester-Calgary commented 3 years ago

Yes but I can't have the field parameters change! shp file or otherwise. Look at the exact parameters of the disposition.shp fields. The output file needs to have the EXACT same field parameters. What I am saying is whenever you select "Replace with displayed values" that field gets output as a 254 character string NO MATTER what the field parameters were before export. If that is intentional that would be ridiculous. vr1 This image is how the fields are set in the dispositions.shp. They need to be exported with the exact same parameters as a shp file.

Mikester-Calgary commented 3 years ago

Sorry wrong image.

Mikester-Calgary commented 3 years ago

disp_shp This is the template. The previous one is post-export. Note the field parameter changes.

gioman commented 3 years ago

Yes but I can't have the field parameters change!

@Mikester-Calgary I'm not saying there is no issue here, I'm just adding more details about when this happen. And it surely happen if you save as shp, but not as gpkg. This could be an important pointer for a developer that want to give this a look.

github-actions[bot] commented 3 years ago

The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale". If you would like to continue with this issue, please provide any missing information or answer any open questions. If you could resolve the issue yourself meanwhile, please leave a note for future readers with the same problem and close the issue. In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this issue. If there is no further activity on this issue, it will be closed in a week.

Mikester-Calgary commented 3 years ago

It seems to me that changing data parameters on export would warrant someone's interest.