I have created a csv file that contains the coordinates for a series of polyline vectors and I am trying to load it into Midvatten's obs_line table. I have made several attempts at this but the data gets loaded using all fields except the geometry field. I first tried the layout given in the tutorial example data set:
WKT;obsid;name;place;type;source
"LINESTRING (136518.11581965966615826 6972638.38746192120015621,136526.23101053971913643 6972634.87753117084503174,136527.8896709508553613 6972634.69279802031815052,136531.11793618529918604 6972632.84546670503914356)";BE1;BE1;Beeston;line;connect_obs_points
I used the import dialog box that is summoned by 'Import data to database' > 'Import data using general csv format' > load from file and chose UTF-8 and then file and then chose the destination as obs_lines. All 78 rows were loaded minus the geometry. I deleted the data and tried again changing the first item on the header from 'WKT' to 'wkt_geom'. I had seen 'wkt_geom' in the obs_point attribute table and thought it might be the correct form but the geometry still failed to load.
So finally I deleted the data once more and rearranged the csv table to match the column list using the column name 'geometry':
obsid;name;place;type;source;geometry
BE1;BE1;Beeston;line;connect_obs_points;"LINESTRING (136518.11581965966615826 6972638.38746192120015621,136526.23101053971913643 6972634.87753117084503174,136527.8896709508553613 6972634.69279802031815052,136531.11793618529918604 6972632.84546670503914356)"
This time I no longer got the warning that I had loaded data without geometry, so I thought it may have worked. But the attribute table did not appear to have geometry in it. I wondered if the geometry was hidden from view so I tried running a section plot and got the following python error:
if geom.wkbType()==QGis.wkbLineString:#...and that the activelayer is a line vector
Attribute Error: 'NoneType' object has no attribute 'wkbType'
I assume that this is telling me that there is no geometry.
How do I need to change the csv file to get the geometry to load? I guess I could try rounding the coodinates to 1 or 2 decimal places. The large number of decimal places resulted from converting from EPSG 4326 to EPSG 3857.
I have now rounded all the coordinates to 2 decimal places and retried loading with the three different header names as previously ('WKT','wkt_geom' and 'geometry') and did not manage to load the geometry. So have now ruled out rounding the coordinates as a possible solution.