X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



7976 Rate this article:
No rating

Adding transparency to a kml file using new graphics in IDL

This article describes how to add transparency to a kml file using new graphics in IDL.

KML files are formatted as XML files. They are not image files but include the path to the PNG image file that will be displayed in Google Earth when opening the KML file.

IDL does not currently support KML files which include a transparent PNG file. In order to create a KML file with a transparent PNG file the following steps can be completed:

- Create a PNG image with a constant value (30 in the example below) where transparency is required. It can be any byte value (between 0 and 255).

- Save this image as a .kml file: it will generate a _test_image0.PNG in addition to the .kml file. This PNG file does not support transparency because the Save method does not support the TRANSPARENT keyword when working with kml files.

- Rewrite the "_test_image0.PNG" file using the TRANSPARENT keyword. This “_test_image0.png” file should be saved in the same locate as the“_test_image0.png” file generated in the previous step

- Test the KML file in Google Earth

The code example below illustrates these steps.

Code example:

 PRO KML_with_transparency

    ; Reading an image

    world = FILEPATH('Day.jpg', SUBDIRECTORY=['examples','data'])

    read_jpeg, world,im

    ; Setting an area of the image to a constant byte value : 30 for example

    ; This is the area where we would like transparency

    im[*,0:425,0:425]= 30

    ; Displaying the image

    arctic = IMAGE(im, LIMIT=[51, -161, 78, -52], $

        GRID_UNITS=2, IMAGE_LOCATION=[-180,-90], $

        IMAGE_DIMENSIONS=[360,180], MAP_PROJECTION='Stereographic', $

        /CURRENT, NAME='Arctic Research', BACKGROUND_color=[30,30,30])

    ; Generating the kml file

    arctic.save,'c:\_user\_temp\test.kml'

    ; Replacing the png file automatically creating at the step before by a new one supporting transparency.

    arctic.save,'c:\_user\_temp\_test_image0.PNG', TRANSPARENT=[30,30,30],BORDER=0

 END

 

 

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »