[GIS] Z values in kml

kmlqgis

My goal is to create a KML line and/or polygon where the z-values of the vertices equal the z-values from point data (where the csv has a Z field).

So far, I have created a spreadsheet which, given a couple of data inputs, autogenerates a large list of points (X, Y and Z values). The points can be grouped a few different sections (e.g. poly1, poly2 etc with each poly consisting of 20 or so nodes).

I carefully added fields for the purposes of autogenerating lines and or polygons in QGIS using the Points2One plugin.

So, now I have one layer with a couple of shapes (lines or polygons) using the Points2One plug, but it only provides one z value per shape.

I now also have another layer with a z-value for each node.

What I need to do now is incorporate the two layers into a KML, where the coordinates noted in the code also consists of the z-value.

I saved as the polygon or line layer as a KML. Each shape looks something like this in the text editor:

</Schema>
<Folder><name>experiment2</name>
  <Placemark>
                <Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
                <ExtendedData><SchemaData schemaUrl="#experiment2">
                                <SimpleData name="Number">13</SimpleData>
                                <SimpleData name="ID">N_A_IHSL2</SimpleData>
                                <SimpleData name="E">379209.579000000030000</SimpleData>
                                <SimpleData name="N">6947509.932000000000000</SimpleData>
                                <SimpleData name="Z">151.000000000000000</SimpleData>
                                <SimpleData name="Dist_Par">-60.000000000000000</SimpleData>
                                <SimpleData name="Dist_Perp">-4000.000000000000000</SimpleData>
                                <SimpleData name="E_Dif">-2635.209433000000000</SimpleData>
                                <SimpleData name="N_Dif">-3009.862329999999900</SimpleData>
                                <SimpleData name="Z_Dif">145.000000000000000</SimpleData>
                                <SimpleData name="RWY">N</SimpleData>
                                <SimpleData name="AppTO">_A_</SimpleData>
                                <SimpleData name="Node">HIS</SimpleData>
                </SchemaData></ExtendedData>
      <LineString><altitudeMode>relativeToGround</altitudeMode><coordinates>
151.83745280810635,-27.583204004361775 
151.82742836624948,-27.592916099990077 
151.83099388901749,-27.537821959903887 
151.77613171577133,-27.590962209266038
</coordinates>
</LineString>
</Placemark>

As you can see, all the coordinates are there for the shape (the x,y) but there is no z.

How do I automatically append the z value in the KML such that each vertex also incorporates the z value?????

Best Answer

I've come up with a workflow that works for me.

  1. Create UTM coordinates in Excel with x, y and z values.
  2. Save as this Excel sheet as CSV.
  3. Import the CSV into QGIS.
  4. Reproject the CSV from UTM into WGS84 (lats and longs).
  5. In the reprojected layer, add coordinates values to the attribute table.
  6. Save as the reprojected layer with the added coordinate values in the attribute table into a CSV.
  7. Open the newly created CSV, delete all columns except for the lats, longs and Z values.
  8. Copy and paste the three columns into a KML text editor between the tags and load the KML into Google Earth.

I feel like there is a much quicker and more elegant way of doing it but it does the job.

Thank you all for your responses!

Related Question