Just follow download/install instructions here: Ī zoologist in South Africa used this same code I'm helping you with. QGIS is, in my humble opinion, better than ArcGIS at dealing with different types of data formats and it is better at handling large data files (ArcGIS will choke on data sets that QGIS handles easily). If you're having trouble reading KMZ/KML in ArcGIS, I honestly suggest using QGIS. Final Suggestion if All Else Fails: use QGIS That line also creates the dbf, prj, cpg, shx and gif files.
to_file( 'test.shp', driver = 'ESRI Shapefile')
The next step is enabling KML reading in fiona (fiona is the Python library to read and write geospatial files).Ī. Then try to import geopandas if it works without error, you're good!! import geopandas as gpd.
The instructions on how to read a KML/KMZ in geopandas were inspired from this post.įirst you need to install geopandas and make sure it's installed in the Python interpreter that you use for ArcGIS. There's another option too! You could just use geopandas. Try that, and if it works, awesome! If not, paste the stack trace. You'll make an edit at one specitic line line 103-105. You can skip it to see if you're getting the result you need. Let's get to your solution! The First Solution: Adding a New Line to Skip the Errorīased on your error, there's one bad key. Some details below may not apply to you, but I'll give it my best go. I'm want to write this so any level of Python user can understand.Īlso, understand it will be difficult for me to debug your exact issue since I don't have the file it's like I'm trying to reach a door on the other side of a dark room that I vaguely remember. If the help seems overly simple or extensive, keep in mind the purpose. This response provides instruction in detail because I want to make sure you have everything you need, but I also want to have this instruction for anyone that would come after you.
Upfront, I apologize for the lengthy explanations. ' csv, geodataframe, and/or pandas dataframe.') 'Valid output types are geojson, shapefile,' ' you entered a correct output file type. Raise ValueError( 'The conversion returned no data check if' Raise ValueError( 'The Shapefile conversion did not create a ' Raise ImportError( 'This operation requires shapely. geometry import Polygon, LineString, Point bufferįunction to convert string objects to Python spatial objectsĭata = row. strip( ' \n \t')Įlif name = "name" and self. If name = "Placemark": # on start Placemark tag inName = False # handle XML parser eventsĭef startElement( self, name, attributes): # plot this new file, use %matplotlib inline if you are in a notebookĪ = keyholemarkup2x('DC_Quadrants.kml',output='shp')
Sample files to test (everything doesn't work, but most do)Ī = keyholemarkup2x('LGGWorldCapitals.kmz',output='gpd')