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:

"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':

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.

1 Answer 1


Remove the " from the geometry column and try again.

Also, make sure you choose the geometry column from your csv-file in the drop down list for the geometry column.

I tried the tutorial obs_line like this and it worked with midvatten version 1.4.8:

LINESTRING (15.664773012790691 60.529872855254261,15.676193301162783 60.540999767780256,15.676193301162783 60.540999767780256);vlf03

  • Thanks Henrik, removing the quotation marks and selecting the geometry column from the drop down list seemed to do the trick as I can now use 'section plot' and the vector appears in the right place on the map. However I find it a little disturbing that I still cannot see the geometry in either the attribute table or by looking at the table in database manager.
    – S. OConnor
    Apr 4, 2018 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.