On MSSQL tables/views that have field names with spaces or starting with a number we get the warning 502 re: replacing invalid characters with a _
As we re-injest some of these files into MSSQL and use them in other software we would like to keep the (poorly formatted) field names as otherwise we have to change every reference to the replaced fields. It could also affect AUTHORITY and Confirm etc that's used for asset management.
Is there a switch that allows us to do this?
Here's what I use
ogr2ogr -skipfailures -f "MapInfo File" -lco overwrite=yes -lco launder=no -lco relaxedFieldNameMatch=yes -lco unsetDefault=yes "D:\QG\vw_CONFIRM_PavementCondition.tab" "MSSQL:Server=xxxx;Database=GIS_Test;Trusted_Connection=True" -sql "SELECT * FROM dbo.vw_CONFIRM_PavementCondition" -a_srs EPSG:28354 -t_srs EPSG:28354 -s_srs EPSG:28354
Warning 6: dataset D:\QG\vw_CONFIRM_PavementCondition.tab does not support layer creation option launder
Warning 502: Field name 'Road Pavement Maintenance Grade' contains invalid characters. 'Road_Pavement_Maintenance_Grade' will be used instead.
Warning 502: Field name 'Road Pavement Roughness' contains invalid characters. 'Road_Pavement_Roughness' will be used instead.
Warning 502: Field name 'Road Pavement Profile' contains invalid characters. 'Road_Pavement_Profile' will be used instead.
Warning 502: Field name 'Road Pavement Rutting' contains invalid characters. 'Road_Pavement_Rutting' will be used instead.
Warning 502: Field name 'Road Pavement Overall Condition' contains invalid characters. 'Road_Pavement_Overall_Condition' will be used instead.
Does ogr2ogr.main used within python have some additional functionality not available in the .exe? if so a solution in this would be fine as well.
Column names in MapInfo TAB files cannot start with a number.
See page 262 pitneybowes.com/content/dam/support/software/…. Do you definitely need MapInfo format? Some other formats do not set limits to column names.