Select to view content in your preferred language

KML to Layer Issue- Is what I'm doing supported?

5680
15
Jump to solution
02-11-2022 07:33 AM
Labels (2)
jdruding
Occasional Contributor
I'm evaluating ArcGIS for personal use and so Esri won't answer my question as to whether this is supported or not and directed me here.   I would like to be able to import KML/KMZ with embedded photos.  These KMZ files have tracks and points with photos attached to them and are created in an app called GaiaGPS.  I know that the KMZ file is valid because it works as expected if you import it to Google Earth.  (the tracks are imported and the points have the photos attached properly)
 
I'm using the KML to Layer conversion tool and checking the box to "Include Ground Overlay". The import imports the points and polylines, but when I click on a point with a photo, the pop up shows the image link is broken.  Looking at the values in the pop up field, I can see that it references the photo with format of:
 
"<img src="ae297b388e83811290459c4cfb6f6c8d.jpg">"
 
When looking at the size of the geodatabase, it is clear that the photos are not present after import. (i.e. the geodatabase is very tiny and the original KMZ is 50 MB.)  I would have thought that KML to Layer function would either copy the photos to a location relative to the root of the reference above (the geodatabase folder itself?) or automatically configure the image element in the Pop Up.  
 
Is this functionality supported?
0 Kudos
15 Replies
jdruding
Occasional Contributor

Thanks for letting me know.  Is this an idea I’m able to vote for? 

0 Kudos
Robert_LeClair
Esri Notable Contributor

I looked for existing KMZ/KML and photos as an existing idea but did not see one.  I'd suggest creating one so it gets visibility with the ArcGIS Pro Developers.

0 Kudos
jdruding
Occasional Contributor

This function has been submitted as an Idea.  If you come across this post and are interested in this functionality, please vote for this idea!

0 Kudos
Stefan_Thorn
Frequent Contributor

Hi,

I have wrote a workaround, see also the attached pdf, based on the data of @jdruding It can be improved with python scripts to do all the steps in ArcGIS Pro but I cannot write them.

KML/KMZ data with attachments to ArcGIS Pro

 In this workaround only two photo attachments per feature class can be added. Writing a python script will improve the process and could make it possible to add more photos as attachments to a feature class.

ArcGIS Pro

  1. Use the Tool KML to Layer to convert the KML/KMZ data to a file geodatabase
  2. Result: the data from the KMZ (Track…) is converted to a file geodatabase KML.gdb and added to the TOC:

Stefan_Thorn_12-1652309055086.png

 

  1. In the created geodatabase create attachments on the point layer:
    1. Right click Points > Manage> enable Attachments (Global IDs will also be enabled)

Stefan_Thorn_13-1652309055087.png

 

 

Stefan_Thorn_14-1652309055087.png

 

  1. Open attribute table from the Point layer and add fields:
    1. Photo1 (text, 255)
    2. Photo2 (text, 255)

Excel

The next steps are done in Excel but it would be easier and quicker to use a Python script in Field Calculator à who can writing python script?

 

  1. Select all records, click Copy and paste all records to Excel:
    1. Save your Excel
  2. In the column [PopupInfo] (or other column) information is stored about the attached images in the kml data. We need these filename of the photos to be able add the images as attachments.
    1. i.e. two photos attached

Location: 39.69032; -74.67498<br>

Elevation: 32.8 ft<br>

Time Created: 1/23/22; 4:22:49 PM EST<br>

<img src="5fb5160cf67690I1483434a2806f41547.jpg"><br><img src="715462I148e722e9d1ca07afI146570f14.jpg"><br>

  1. In Excel: Add the next formula in column:
    1. I2 = column [PopupInfo]
  2. Column Photo1:

=SUBSTITUTE(IFERROR(MID(I2;FIND("<img src=";I2)+10;37);"");"""";"")

  1.     Getting the first filename
  2.     Filename of the photos has not always the same length in ,therefor it is possible that the last character “ after .jpg will be added, substitute will remove the “.
  1. Edit the formula to get every filename correct or Step 9
  2. Column Photo2:

=SUBSTITUTE(SUBSTITUTE(IF(LEN(I2)-LEN(SUBSTITUTE(I2;".jpg";""))>4;MID(RIGHT(I2;LEN(I2)-FIND("|";SUBSTITUTE(I2;"=";"|";LEN(I2)-LEN(SUBSTITUTE(I2;"=";"")))));2;38);"");">";"");"""";"")

  1.     The formula will search from right to left in the text.
  2.     If in the text “.jpg” occurs twice the sum is 8 characters and is > 4 and a second filename is in the data, otherwise no output
  •     Getting the second filename
  1.     Filename of the photos has not always the same length in characters therefor, it is possible that the last the characters “ and/or > after .jpg will be added, substitute will remove the > and “.
  1. Edit the formula to get every filename correct or Step 10
  2. Add new sheet “attachments”
  3. Select all data in “Sheet1” and copy as values to sheet “attachments”
  4. In sheet attachments remove all columns except [OID*], [GlobalID], [photo1] and [photo2]
  5. In columns [photo1] and [photo2] correct the few filename extensions.
  6. Add <Null> in de cells that are empty, i.e.:

Stefan_Thorn_15-1652309055089.png

 

  1. Save your excel

Now a nice trick in ArcGIS Pro

  1. If not trusting, use Join to add the filenames in [photo1] and [photo2] from the Excel.
  2. Select the data in column [photo1], right click Copy
  3. Stefan_Thorn_16-1652309055091.png

     

  4. Go to ArcGIS Pro
  5. In attribute table Points click on column name photo1, ctrl-v
    1. The values will be copied into the records
  6. Save edits
  7. Repeat for [photo2]

Import attachments

  1. Tool ‘Add Attachments’

Stefan_Thorn_17-1652309055092.png

 

  1. Import photo1

Stefan_Thorn_18-1652309055094.png

 

  1. For the <Null> values you will get error messages or when a filename is not correct.

Stefan_Thorn_19-1652309055095.png

 

  1. Import photo2
  2. Stefan_Thorn_20-1652309055098.png

     

    1. For <null> values you will get error messages

 

 

 

 

 

Results

popup from the KML data opened in ArcGIS Pro

Stefan_Thorn_21-1652309055121.png

popup from the data converted to file geodatabase

Stefan_Thorn_22-1652309055128.png

 

 

 

jdruding
Occasional Contributor

Wow! Very cool.  I'll have to give this a try!  I don't know Python either, but Ive been wanting to learn 🙂

0 Kudos
AbbyPortwood
New Contributor

Did anyone ever figure this out? I am having the same issue with getting photos stored in my KML to upload. 

0 Kudos