3

I have a number of kml files that have images linked in them. When I try to convert them to tab using FME/UniversalTranslator/QGIS/GlobalMapper I get a tab file which has the spatial location of the points but the attribute table does not include the name of the image. How can I get this? a process entirely in Mapinfo 12 will be ideal.

"<description>&lt;img src=&quot;MAPPT_20151210_110739_-1565318452.jpg&quot; width=&quot;480px&quot;/&gt;&lt;/br&gt;&lt;/br&gt;&lt;a href=&quot;MAPPT_20151210_110739_-1565318452.jpg&quot;&gt;To view original size of image file click RIGHT BUTTON and choose OPEN LINK.&lt;/a&gt;&lt;/br&gt;&lt;/br&gt;&lt;table border=&quot;1&quot;&gt;&lt;tr&gt;&lt;td&gt;Type&lt;/td&gt;&lt;td&gt;Tent&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Comments&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Maintenance Action&lt;/td&gt;&lt;td&gt;No action&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Post Material&lt;/td&gt;&lt;td&gt;Steel&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Sign Material&lt;/td&gt;&lt;td&gt;Aluminium&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Sign Condition&lt;/td&gt;&lt;td&gt;Good&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Post Installation&lt;/td&gt;&lt;td&gt;One post sign&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;User&lt;/td&gt;&lt;td&gt;John Kenna&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Logo&lt;/td&gt;&lt;td&gt;None&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Post Condition&lt;/td&gt;&lt;td&gt;Good&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Date/Time&lt;/td&gt;&lt;td&gt;10-12-2015 11:08&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</description>

So I need MAPPT_20151210_110739_-1565318452.jpg to be put in the "Image" attribute of the generated table along with all the other data in their own attributes.

I have seen similar questions here re: getting the extended data but none of them deal with getting the image name.

I have tried Global Mapper (my go to for this kind of work), QGIS, KML2SHP and FME. QGIS doesn't even separate the extended data (as per comments in How to convert KML to shapefile without losing attributes using QGIS?). The others do this but don't give me the image name.

The only "complex" solution I can think of is to convert to tab in GM Script and then read the kml in python and extract the value between [img src="] and [;] and put this into the tab as value for the image attribute. Surely there's a better solution!

Here a sample dataset -it has the kml, kmz and a shp plus the images. https://drive.google.com/file/d/0BxjBqNsSHofKQkRhWGtPamJTcmM/view?usp=sharing

2

If you are using FME Quick Translator that comes with MapInfo Pro you need to make sure that you specify FME to include this Schema Attribute: kml_description.

This column will afterwards contain the entire string for the image, like:

<img src="MAPPT_20151210_110201_614270222.jpg" width="480px"/></br></br><a href="MAPPT_20151210_110201_614270222.jpg">To view original size of image file click RIGHT BUTTON and choose OPEN LINK.</a></br></br><table border="1"><tr><td>Type</td><td>Village

You might need to "clean" that up a bit if you only want the image name. You can use this update statement to extract the image name from the string:

Update Placemark 
   Set kml_description = Mid$(kml_description
        , (Instr(1, kml_description, "src=") + 5)
        , Instr((Instr(1, kml_description, "src=") + 5)
              , kml_description, ".jpg") - (Instr(1, kml_description
              , "src=") + 1)
        )
  • brilliant. The extraction works well. I tried the code in the update statement and it fails with syntax error. – GeorgeC Dec 17 '15 at 2:04
  • 1
    Make sure the quotation marks are correct and also make it a single line statement in the MapBasic window just to avoid any misinterpretation. I'll check the syntax again but it should work unless I made an error when copying it from the MapBasic window. – Peter Horsbøll Møller Dec 17 '15 at 6:08
  • 1
    Wonderful -works perfectly now. ## Update Placemark Set kml_description = Mid$(kml_description, (Instr(1, kml_description, "src=") + 5), Instr((Instr(1, kml_description, "src=") + 5), kml_description, ".jpg") - (Instr(1, kml_description, "src=") + 1)) ## – GeorgeC Dec 17 '15 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.