0

I try to convert with arcpy (python 2.7.8) 50 KML and KMZ files, that i downloaded from google earth into shapefiles. All files located in many sub-Folders. All Sub Folders are located in one large directory. When i run this code:

import arcpy,fnmatch,os
rootPath = r"C:\Project\gis\layers"
pattern = '*.km*'
for root, dirs, files in os.walk(rootPath):
 for filename in fnmatch.filter(files, pattern):
 print(os.path.join(root, filename))
 arcpy.KMLToLayer_conversion( r"C:\Project\gis\layers" ,r'C:\Project\gis') 

i get an error:

C:\Project\gis\layers\ESD.kml
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000814: Invalid file type
Failed to execute (KMLToLayer).

I red:

Python Script to convert a mass of KMLs to a single fGDB

http://resources.arcgis.com/en/help/main/10.2/index.html#/KML_To_Layer/00120000004w000000/ but didn't understand my code mistake

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jul 27, 2015 at 10:25

1 Answer 1

2

I think you are seeing that particular error message from this line of your code:

arcpy.KMLToLayer_conversion( r"C:\Project\gis\layers" ,r'C:\Project\gis')

arcpy.KMLToLayer_conversion expects a file as its first parameter (KML or KMZ) but you are giving it a folder name.

You could try concatenating the contents of your filename variable, with the appropriate delimiter, onto it.

answered Jul 27, 2015 at 10:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.