2

How do I upload a KML file into QGIS with the attribute data intact? It is present in Google Earth but not when imported into QGIS?

http://data.gov.uk/dataset/sites-of-biological-importance-sbi-in-greater-manchester-as-at-2015-04-28

This is the website which contains the data I need. I need to show the site names on my map, but I am currently unable to do this. My coordinate reference system is: OSGB 1936/BNG (OTFR Enabled).

  • 1
    What steps have you taken thus far and where are you running into issues? – papadoo Jul 15 '15 at 14:44
  • I have made a shapefile which shows the attribute data but appears in the wrong location, it is separate to my other data which is on the CRS mentioned above. I have imported the KML file which appears in the correct place aligned with my other data but has no attribute data with it. I really need to know how to attach attribute data to the KML file. I have downloaded the CSV file which comes up in excel with all the data is there a way I can attach this to the KML IN QGIS? Thanks – Abigail Jul 15 '15 at 15:08
  • As a workaround you can convert KML into some easier format with ogr2ogr. Command would be like ogr2ogr -f sqlite -dsco spatialite=yes output.sqlite gmeu_sbi.kml Spatialite does not alter the attribute names by cutting them to max. 10 characters allowed in shapefiles so I recommend that. – user30184 Jul 15 '15 at 17:42
3

I checked out the site, and found a good way to do this. KML is not the best format for handling attributes (as you found), but they also allow you to get the data as a CSV, which is a great format.

Download the CSV, in QGIS, choose Layer > Add Delimited Text Layer... Pick WKT as the geometry interpreter, and choose the field that says it has WKB geometry in it (which actually looks more like WKT anyway). I had not used this dialog before, and it's actually really great--more straight-forward and flexible than the one in ArcGIS.

That should do it. Once the layer is on the map you can save it as a shapefile if you like, and also assign the correct CRS to it.

EDIT: I found that the data from the site you linked is actually in WGS48 Web Mercator, EPSG 3857, not the national grid system as it claims.

  • Thanks I have now got it uploaded with the attribute data available but it is still not in alignment with my other data. My other data all aligns but this KML will not! The other data i'm using is on a national scale that could be why? But I have no choice but to use this national data. geostore.com/environment-agency/WebStore?xml=environment-agency/… If you scroll to the bottom of this I used Sites of Special Scientific Interest (3 from bottom) downloaded as a shapefile and I need it to align with this. Thanks – Abigail Jul 15 '15 at 15:26
  • So basically I can get the KML in the correct location but with no attribute data. The CSV will go in the wrong location but with attribute data. Please see if you can try and align the CSV with the Sites of Special Scientific Interest? @mr.adam – Abigail Jul 15 '15 at 15:36
  • Ok, it's a CRS issue. While the first site says that the data is in the national grid, it's actually in Web Mercator WGS 1984 projection, which is EPSG 3857. The shapefile is in the national grid. Once you correctly define the CRS for each layer, they line up just fine. – mr.adam Jul 15 '15 at 15:56
  • So I need to change the SBI shapefile to the Web Mercator WGS 1984 projection? To do this do I right click that layer and click 'Set Layer CRS'? And then I change both to this Web Mercator (...) projection? Thanks – Abigail Jul 15 '15 at 16:12
  • Each layer in the table of contents needs to have the correct CRS assigned to it. The SBI layer needs epsg 3857, and the sites of special interest needs the national grid. Yes, that's the way you set the CRS, and you find the ones you need with the filter. Here's some information on how QGIS handles CRS. – mr.adam Jul 15 '15 at 16:15
1

Download the kml, and go to this page: http://www.zonums.com/online/kml2shp.php you can export here the kml to shape format, and then load to qgis (and change the wgs84 system to epsg27700 (osbg36). Hope it helps.

  • When Ive tried this i've uploaded the kml file, but its a google earth one so it wont work. It says no entities found. From the first link I posted in my question is there a way to download the KML without it opening in google earth? (so its its own file?) Thankyou – Abigail Jul 15 '15 at 15:47
1

Converted the KML to Shapefile using FME

enter image description here

FME simple process is (read then write) enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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