[GIS] Extrude Shapefile to KML based on field value

extrudefwtoolsgdalkmlqgis

I would like to extrude shapefile polygons to a KML based on a value stored in the attribute table. I am hoping to do this using open source software (QGIS, FWTools, GDAL, etc.). I looked at ogr2ogr using the -zfield option, but the polygons were not extruded as a KML, they were just an outline.

Any help would be appreciated,

Thanks…

Best Answer

You can use a specific column for extruding a shapefile to a kml using GDAL's ogr2ogr utility, but only if it's been compiled with libkml support. If it's been compiled with libkml support, that will become the default KML driver.

So you can try the following, first specify the zfield to be used in an environment variable, then run the ogr2ogr utility:

# Use **export** if on linux, but use **set** command instead if on Windows!
export LIBKML_EXTRUDE_FIELD=zfield
ogr2ogr -f libkml output.kml input.shp

...where zfield is the name of the actual column that contains the z values

Then there is also the creation option available for the regular KML driver, but this doesn't specify a field for extrusion, only the altitudeMode:

ogr2ogr -f KML output.kml input.shp -dsco AltitudeMode=absolute

The other AltitudeMode options are in the link I gave there, but the default is relativeToGround.