3

I am finding that more and more I am being sent KML files to be converted into shapefiles to be used for mapping/analysis etc. I am finding it monotonous using the Export KML to Layer tool, then re-exporting the layer (right clicking on layer in ToC and exporting as shapefile.) This seems like a lot of unnecessary work and creates a lot of the dreaded 'temp' files.

I would like to create a model to speed up the process. I am getting stuck however finding a way to export the output layer (from running the Export KML to Layer tool) to a shapefile.

Is there a way to do this? Or alternatively, export the .gdb the is also exported from running the Export KML to Layer tool?

I am also open to suggestions on how to do this using Python!

  • 2
    CopyFeatures_management? Select_analysis? FeatureClassToFeatureClass_conversion? any of these fit the bill for you? Whenever I get KML files I export them from QGIS, the Esri tool is just a little too unreliable for my liking... OGR2OGR will also convert to shape if you're comfortable with command line. – Michael Stimson Apr 28 '15 at 22:43
  • 1
    There is also an ArcScript arcscripts.esri.com/details.asp?dbid=15603 that reads the KML directly... it is for ArcGis 9.2 (gp = arcgisscripting.create()) but should still work in ArcGis 10, any recent changes to the KML specification may not be compatible. – Michael Stimson Apr 29 '15 at 0:04
  • I have tried those tools Michael but no luck. I will check out the ArcScript to see if that works for me. Thanks. – ChrisA Apr 29 '15 at 20:12
1

The process seems to involve two steps:

  1. KML To Layer to convert a KML file to a geodatabase feature class (it cannot create a shapefile as output)
  2. Feature Class To Feature Class to convert a geodatabase feature class to a shapefile

Consequently you should be able to:

  1. open a new model
  2. drag these two tools in
  3. join the output of 1. to the input of 2.
  4. create parameters from 1.

The ModelBuilder documentation is well worth having open as you try this.

  • Have you looked at the script that I linked PolyGeo? it's not bad as far as scripts go (maybe I just have low expectations) it actually reads the KML as text and compiles geometries from it... it could easily be iterated for points, lines and polys (as KML can have multiple geometry types); I don't know enough about KML spec to discern if it will read the most recent updates. Esri KML to layer tool for some reason doesn't always work, which is why I use QGIS for KML. – Michael Stimson Apr 30 '15 at 21:44
  • @MichaelMiles-Stimson I don't have a great need for KML conversion. I was just surprised when I read that the asker was using what sounded like a much longer than necessary procedure for the simplest scenario of KML to shapefile when I had been assuming that the KML To Layer writing feature classes would have included shapefiles as an output (like FCtoFC). – PolyGeo Apr 30 '15 at 21:54
  • I get them frequently, up to 3 a day. It would be just as simple if KML to Layer always worked the same as the other tools; I lost a polygon in the conversion a while ago which caused massive problems in the flow-on effects, since then I've used QGIS and haven't dropped a feature. Perhaps the tool is now more reliable, I can't take that chance. – Michael Stimson Apr 30 '15 at 22:14
  • @PolyGeo I had originally tried the process you posted. A problem arises when the KML file has multiple geometries. Usually it is points and polylines. The output when running the KML to Layer tool is a geodatabase not individual feature classes, so it doesn't allow me to use this output as an input feature for the Feature Class to Feature class tool. – ChrisA May 5 '15 at 16:29
  • @ChrisA If processing multiple geometry types is a requirement then that is best made part of your question. However, to handle the simplest case first, I think you should edit your question to focus it on explicitly creating a model/script to convert just a single geometry type from KML to shapefile. – PolyGeo May 6 '15 at 2:54
0

If we use the Feature Class to Feature Class it won't work, as Geodatabases cannot be converted!

The solution is to use the "Select Data" tool in order to export the shapefiles we want to, from the .gdb! Then use the "feature to polygon" tool!

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.