2

I have a CSV file containing geodata in WKT in one column. The geometry type is GEOMETRYCOLLECTION. How do I import this to QGIS with one layer per geometry type (POINT and LINESTRING in this case)?

Here's a simplified feature example:

id,title,description,features,category,date
79042,Ausbau Wismar–Rostock,"Ich schlage einen zweigleisigen Ausbau und die Elektrifizierung Wismar–Rostock...","GEOMETRYCOLLECTION(POINT(11.474493907902323 53.89207715945744),LINESTRING(11.47502100706609 53.89112033371444,11.474763515000689 53.89162614941653))",Regionalverkehr,2023-03-24

I used Layer > Add Layer > Add Delimited Text Layer... in QGIS 3.22 and I can select either single geometry types or "Detect" for WKT. I would have expected a new window to select one or more geometry type layers to create from the source. But there is no such selection. An empty layer with no data is being created.

enter image description here

It works if I split the geometry into one column for points and one for lines.

id,title,description,point,line,category,date
79042,Ausbau Wismar–Rostock,"Ich schlage einen zweigleisigen Ausbau und die Elektrifizierung Wismar–Rostock...","POINT(11.474493907902323 53.89207715945744)","LINESTRING(11.47502100706609 53.89112033371444,11.474763515000689 53.89162614941653)",Regionalverkehr,2023-03-24

But my original data has almost 15k rows, so the manual solution does not work. Also, it has more than one point and one linestring per feature.

0

1 Answer 1

3

I converted your data into GeoJSON and tried to open that with QGIS but it cannot read the geometry nor the attributes correctly. I believe that QGIS cannot really handle geometry collections.

As a workaround I suggest to pre-process the data with ogr2ogr first by exploding the geometry collections.

Usage example:

ogr2ogr -f GeoJSON geomcol.json geomcoll.csv -explodecollections -oo geom_possible_names=features

QGIS can open the resulting GeoJSON file and it suggest to create separate layers for each geometry type.

0

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.