1

I have imported a .kml file into QGIS, and the data is all shoved together into a single field like this: delimeter Fine, it's pipe delimited - easy to change the delimiter like in LibreOffice calc imports I thought. But could not find a solution within QGIS.

Next attempt: change the delimiter in the kml file to the common default comma delimited using Sed: sed -e 's/|/,/g' in.kml > out.kml

Still no joy - it looks exactly the same as above, only with commas instead of pipes. So someone please help me, and I'm sure it will be of use to others.

(P.s. a colleague and I have tried the same thing in ArcGIS and the same problem is encountered).

6
  • Are you sure this is a KML file or is it really a CSV? You should be able to add a KML file into QGIS using the Layer->Add Vector Layer menu.
    – gsherman
    Apr 8, 2013 at 21:38
  • Hi gsherman, yes I'm sure it's a kml file. I added it using the method you suggested. Its format is as follows: Apr 8, 2013 at 21:43
  • <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="opengis.net/kml/2.2"> <Document> <Style id="transBluePoly"> <LineStyle> <width>1.5</width> </LineStyle> <PolyStyle> <color>30ffa911</color> </PolyStyle> </Style> <Style id="labelStyle"> <IconStyle> <color>ffffa911</color> <scale>0.35</scale> </IconStyle> <LabelStyle> <color>ffffffff</color> <scale>0.35</scale> </LabelStyle> </Style> <Placemark> <name>9840229084|2013-03-06 13:41:34.0|rent|...</name> Apr 8, 2013 at 21:44
  • Even if it were not a .kml file, the same question remains: how to add delimiters to the attribute table so more columns are created (e.g. perhaps you want "08 04 2013" to be represented by three separate columns by making space " " the delimiter). Apr 8, 2013 at 21:46
  • 4
    Whoever generated the KML stuffed additional detail into the name tag. QGIS properly creates the attribute table based on the tags in your KML. There is no way to force additional columns to be created when opening it. You can do it by converting to another format (e.g. CSV), restructuring it, and loading it---or by adding additional attributes to the KML file.
    – gsherman
    Apr 8, 2013 at 23:36

1 Answer 1

1

You can try this:

  • create a new ID field from the first part of the name tag using RegExp functions in field calculator

  • save the layer as CSV file

  • expand the CSV externally like you did with sed

  • add the expanded CSV as delimited text layer

  • join by attribute the kml layer and the delimited text layer using the ID created above.

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.