Hyperlinks to local docs – ArcMap and Google Earth

Posted by in ArcMap, Data, Design, GIS

As you should know google earth pro is now free. Yesterday, I set up a kml with hyperlinks to local pdf’s via a relative link.

I can’t show what I was working on but I’ve recreated it with some public data.

In arcmap, I have 4 USGS quad boundaries.


I also have the corresponding quad pdfs saved within my project folder in a folder named pdf.


My goal is to have a kml of the boundaries of these quads, each with a popup containing a hyperlink that will open the correct pdf.

In arcmap, I hide all the fields except the quad name – well, I usually keep the FID and shape field on as well because I’ve seen some strange behaviour when turning these fields off.


Now add a new string field named “Hyperlink” 250 characters long.


Right-click the hyperlink field heading and choose calculate field. Now create html hyperlinks to the pdf’s stored in my project folder. The string in the hyperlink field needs to be formatted similar to:
<a href=’pdf\quad_name.pdf’>Text shown in link</a>

The “QUAD_NAME” field can be substituted for both the href and hyperlink text portion of this string.


Change the parser to python.


Now enter the following expression:

“<a href=’pdf\\”+!QUAD_NAME!.replace(” “, “_”)+”.pdf’>”+!QUAD_NAME!+”</a>”

Note that I’ve used single quotes around the path. Also note the double backslashes and the syntax to replace spaces in the existing QUAD_NAME attribute with underscores, to match the pdf filenaming, and add the .pdf extension. Between the opening and closing <a> tag is the attribute from the QUAD_NAME field, this is what will be displayed as the text of the hyperlink.


The hyperlink field should look like this now. This is a realative link, the hyperlink will look for the pdf within the pdf folder “pdf\Clayton.pdf” in the same location as the kml file. In other words the final kml containing these hyperlinks should be in the same folder as the folder named “pdf” which contains the document that will be opend via the hyperlink.

The Hyperlink attribute now reflects a valid html hyperlink.

<a href=’pdf\Clayton.pdf’>Clayton</a>


This link can be an absolute path as well, or a url, just replace the path within the single quotes with an absolute path (pro tip – this can be a network location) or valid url.

<a href=’pdf\Clayton.pdf’>Clayton</a>
<a href=’R:\GIS\USGS\pdf\Clayton.pdf’>Clayton</a>
<a href=’http://www.bgcarto.com’>BG Carto</a>

Now use the layer to kml tool in arcmap to export the layer with hyperlinks to a kmz. The tool is called layer to kml, but it only exports kmz, go figure.


This can go in a temporary location, because with the relative link in the hyperlink the output kmz must be opened and saved as kml in the same location as the pdf folder. Even if the output kmz was saved to the same directory as the pdf folder at this point, the hyperlinks would not work. They are relative as will be looking inside the compressed .kmz (which very basically is a folder).

Now open the kmz in google earth. The license key for google earth pro is GEPFREE if you don’t already have it, go get it.

If you click one of the features to open the pop up window, note that the hyperlink does not work.


In the google earth (GE) menu bar go Tools>Options. In the general tab, check “Show web results in external browser” under display and check “Allow access to local files and personal data” in Placemark balloons. The second preference is what will allow us to open the corresponding quad pdfs. When you check the second box a warning will appear, press enable. Then hit ok.


Now right click the layer in the GE table of contents and choose Save place as.


Now navigate to the directory containing the pdf folder (with the quad pdfs inside) and change the file type to .kml (very important).


Close google earth and navigate to the kml saved in the last step. Open and test the hyperlink.

The hyperlinks in the info windows should now open the corresponding pdf for each index feature.


Keep in mind that relative links that contain spaces can be problematic and that the relative link style will not work with the raw kmz output from arcmap, at least not for this workflow. If you are creating this for internal purposes and everyone has access to a common location, it’s probably best to use absolute paths.

I needed to do this because my client is not GIS savvy and prefers to see spatial data in google earth. I have a workflow that includes many grouped layers in a master mxd. These group layers are translated to .lyr files programatically and those .lyr’s are in turn saved as kmz, then manually the kmz’s are simulateously opened and saved together as a kml. With the proper formatting in the attribute tables of the GIS data, the hyperlinks carry over into the final product and allow my client to see the boundaries of certain maps and data and open the corresponding maps very quickly.


  1. Camilo
    September 30, 2015

    Thanks for your help. There is a lot of things to improve about data transfert between ArcGIS and Google Earth. Many clients are asking for more spatial data in GE right now.

  2. Jill
    December 1, 2015

    This didn’t work for me. I tried using an absolute path on my C:\

    • Jill
      December 1, 2015

      This is an example of one of my hyperlinks:


      • Brian
        December 1, 2015

        Hi Jill, If the hyperlink you’re using is ‘\FoodCrew2015\GroveForm_20151116_35.pdf’ the kml should be in the same directory that contains the FoodCrew2015 directory. It won’t work if the kml is in the FoodCrew2015 dir. I can check it out if you zip it up and send it my way.

        • Brian
          December 1, 2015

          also, might want to remove the rel=”nofollow” parameter

  3. Kat S.
    June 30, 2016

    One step further: How can I add scripting that opens the .pdf to a specific page?

  4. Kat S.
    June 30, 2016

    One more thing:


    ?/A Page=5=OpenActions

    does not work 🙁

    • Aaron
      March 24, 2017

      Did you ever figure out how to add scripting that opens the .pdf to a specific page of a document?


Leave a Reply