Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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).

share|improve this question
    
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 '13 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: –  RobinLovelace Apr 8 '13 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> –  RobinLovelace Apr 8 '13 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). –  RobinLovelace Apr 8 '13 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 '13 at 23:36
show 1 more comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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