EXPORT2KML

Export to Google Earth KML or KMZ


EnvironmentsPYTHON :: EASI :: MODELER
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: Example :: Related

Back to top

Description


EXPORT2KML lets you export raster, vector, and bitmap data to KML or KMZ format. Exporting the data to KML or KMZ format allows you to view the data in virtual globe programs, such as Google Earth.
Back to top

Parameters


export2kml(mfile, dbic, dbib, dbvs, filo, mask, maskfile, foptions)

Name Type Caption Length Value range
MFILE * str Input file name, directory, or text file 1 -  
DBIC List[int] Input raster channel(s) 0 - 3  
DBIB List[int] Input bitmap channel(s) or layer(s) 0 - 1  
DBVS List[int] Input vector segment(s) 0 - 48  
FILO str Output KML file name 0 -    
MASK List[int] Area mask 0 - 4
MASKFILE str Area mask file 0 -    
FOPTIONS str Z-coordinate processing options 0 -    

* Required parameter
Back to top

Parameter descriptions

MFILE

Specifies a particular file or multiple files to be processed. Wildcards (*) can be used.

MFILE can be set using any of the following options:

If the text file option is used, the following general rules apply:

The column structure of the text file specified in EXPORT2KML is:
MFILE;DBIC;DBIB;DBVS;FILO;MASK;MASKFILE;FOPTIONS

If the combination of parameters is invalid for an input file in MFILE, a warning is issued and the file is not processed. However, if the output file or its associated directory already exists, the processing is aborted.

DBIC

Specifies the channel(s) in the input file to be exported. Only channels that have a pixel depth of 8U can be exported. You can specify one channel or three channels for export. EXPORT2KML generates an error if the number of channels is not 0, 1, or 3.

If you export one channel and it contains metadata on PCT information, a pseudocolored image corresponding to the PCT information is displayed in Google Earth. When three channels are specified, the system processes the result into an RGB colored image. The order in which you list the channels dictates the color output of each channel. For example, if you specify 10, 2, and 8, channel 10 becomes red, channel 2 becomes green, and channel 8 becomes blue.

DBIC can be set in any of the following ways:

DBIB

Specifies the bitmap channel or layer to be exported. Only one bitmap can be specified.

DBIB can be set in any of the following ways:

DBVS

Specifies the input vector segment(s) to be exported.

EXPORT2KML can export any number of vector segments.

In addition, EXPORT2KML can export topological data and can convert topological polygons to whole polygons and topological lines to lines.

DBVS can be set in any of the following ways:

FILO

Specifies the name of the KML or KMZ output file. The KMZ file is a compressed (zipped) KML file.

When you specify the file name, you must also define the file extension as .kml or .kmz.

CAUTION:
If you specify a file name that already exists, the system aborts the export function.
FILO can be set in any of the following ways:

MASK

Specifies the areas of the data to be exported.

You can define these areas using three types of mask boundaries: window, bitmap, and vector.

For a window mask, you can define a rectangular area by specifying a starting pixel (Xoffset) and line (Yoffset) reference, and a window size (Xsize and Ysize).

For a bitmap mask, you can specify the number of the bitmap segment that you want to use. All of the pixels within the specified segment, having a pixel value of 1, define the area where input data has to exist to be exported.

For a vector mask, you can specify the number of the vector segment that you want to use as a mask. If the segment is a polygon layer, EXPORT2KML clips the input data along the polygon boundary. If the segment is not a polygon layer, EXPORT2KML uses the extents of the segment to define the mask area.

Note: EXPORT2KML chooses a bitmap segment over a vector segment for defining the mask area, if both segments share the same segment number.
MASK can be set as follows:

If you specify a MASK but not a MASKFILE, EXPORT2KML obtains the MASK from the file specified for export.

MASKFILE

Specifies the source file name in which the MASK parameter resides. The file you specify can be separate from the rest of the data that is set for export. EXPORT2KML reads the setting in MASK and automatically looks for the associated file name in MASKFILE.

If you do not specify a MASK, EXPORT2KML ignores any setting specified in MASKFILE. If you specify a MASK but not a MASKFILE, EXPORT2KML obtains the MASK from the file specified for export.

FOPTIONS

Specifies the file creation options. For EXPORT2KML, FOPTIONS has the key "z", which is used when exporting vectors. The z-value specifies elevation values for vectors. Therefore, using the key "z", you can manipulate the z vertices of lines that you have specified for export.

FOPTIONS can have one of the following settings for the z-value:

By specifying a z-value or leaving it blank, you can manipulate the look of lines in Google Earth. EXPORT2KML processes the z-value of lines using the KML-supported altitudeMode and tessellate tags.

If you specify the z-value with a z-coordinate or attribute value, EXPORT2KML sets the altitudeMode to absolute and does not specify tessellate. This results in lines appearing in Google Earth at the specified z-value. The lines dip out of sight in areas where the Google Earth elevation value is higher than the z-value.

If you do not specify the z-value, EXPORT2KML sets altitudeMode to ClampToGround and tessellate to 1. This results in the lines appearing on the ground and contouring to the underlying Google Earth terrain.

Back to top

Details

During the export, EXPORT2KML can perform the following tasks:

If you are exporting data that is not in Lat/Long WGS84 projection, EXPORT2KML detects and reprojects the data to Lat/Long WGS84 during the export.

For rasters and bitmaps, EXPORT2KML applies the following settings during the reprojection:

If you want to specify your own reprojection settings, you can run REPROJ before you run EXPORT2KML. However, if your files have no projection, EXPORT2KML cannot reproject your files and will therefore generate an error.

Using built-in GDB technology, EXPORT2KML detects the pixel size of rasters and bitmaps and tiles them to 256x256 pixels. The tiles are saved as a subset to the newly created KML file. When the KML file is viewed in Google Earth, the tiles are pulled in when a greater resolution is necessary.

During the export, EXPORT2KML creates the KML file and a folder bearing the same name as the KML file but appended with "_files". For example, if the KML file name is irvine, the folder name becomes "irvine_files". The KML file and the folder appear in the directory location that you specified. If you specify KMZ as the export format, the KMZ contains the KML file and folder in compressed form. The folder contains tiles and overviews of the KML file. These tiles and overviews are used as super-overlays by Google Earth for optimal display.

Back to top

Example

The following is an example of the final result of EXPORT2KML when you specify a text file for the MFILE parameter. Each line in the text file is a complete MFILE entry. The MFILE entries are in a column structure, where each column corresponds to a parameter. The information between the semi-colons is the value of the parameter. Each line in the MFILE represents a set of parameters.

The column structure of the text file specified in EXPORT2KML is:

MFILE;DBIC;DBIB;DBVS;FILO;MASK;MASKFILE;FOPTIONS

The following are example contents of the list.txt file:

"file1.pix";1;2                     
"file2.pix";2;;;;9;"irvine.pix"
"file3.pix";;;11;"file3.kml"  
 

The above contents of the list.txt file is equivalent to:

 (MFILE=file1.pix, DBIC=1, DBIB=2)
 (MFILE=file2.pix, DBIC=2, MASK=9, MASKFILE=irvine.pix)
 (MFILE=file3.pix, DBVS=11, FILO=file3.kml)

The following are EXPORT2KML's parameter settings, which are overwritten by the parameter settings in the text file (list.txt):

from pci.export2kml import export2kml


mfile = "list.txt"   # folder of data-set files
dbic  = [3]
dbib  = [2]
dbvs  = []
mask  = [5]
filo  = "out.klm"
maskfile = ""        #from input file list
foptions = ""

export2kml(mfile, dbic, dbib, dbvs, filo, mask, maskfile, foptions)

The results are as follows:
  • For file1.pix, the portions of DBIC 1 and DBIB 2 that are covered by the bitmap (or vector) in segment 5 of file1.pix are exported to out.kml.
  • For file2.pix, the portions of DBIC 2 and DBIB 2 that are covered by the bitmap (or vector) in segment 9 of irvine.pix are exported to out.kml.
  • For file3.pix, the portions of DBIC 3, DBIB 2, and DBVS 11 that are covered by the bitmap (or vector) in segment 5 of file3.pix are exported to file3.kml.

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.