jquist1

Problem importing parsed Google Earth coordinates to shapefile

Discussion created by jquist1 on Apr 13, 2013
Latest reply on Apr 15, 2013 by MKennedy-esristaff
Hello, and thank you for reading my posting.
I am a GIS student new to coding and I am hoping for some help from you the professionals.
I am writing a custom python script which takes in a user defined Google Earth kml file (polygons only), parses the kml with BeautifulSoup, creates a new shapefile, and populates the shapefile with the polygons and descriptive data. (I am not using the kml to layer tool.) Google Earth coordinates are exported in decimal degrees.

Everything works fine as far as the shapefile table goes but the points will not create feature geometry.


My Code:

sr = arcpy.SpatialReference(4326)  # This is the code for WGS 84 GCS used by Google Earth
arcpy.CreateFeatureclass_management("C:/Temp", shapefile,"POLYGON", "#", "#", "#", sr)
arcpy.env.XYTolerance = '0.0000000000000000001 Degree'

.............parsing steps........

for placemark in placemarks:

      featCoordList looks like this [[u'-00.0000000000000', u'-0.000000000000000', u'0'], [u'-00.00000000000000', u'-0.000000000000000', u'0'], [u'-00.00000000000000', u'-0.000000000000000', u'0'], [u'-00.0000000000000', u'-0.000000000000000', u'0'], [u'-00.00000000000000', u'-0.000000000000000', u'0']] with an unlimited number of points possible

      try:
            point = arcpy.Point()
            array = arcpy.Array()
                       
            # For each coordinate pair, set the x,y,properties 
            for coordSet in featCoordList:
                point.X = float(coordSet[0])
                point.Y = float(coordSet[1])
                array.add(point)

            polygon = arcpy.Polygon(array)
                                   
            #use an insert cursor to put each polygon feature into the new shapefile
            ic = arcpy.da.InsertCursor(shapefile, ["SHAPE@", "Name"])
            newRow = (polygon, name)
            ic.insertRow(newRow)
            
            array.removeAll()          
            del ic

Does anyone out there have any idea why I have no geometry?
Further, if I multiply by ten, I get output geometry but the points are obviously not where they are supposed to be.

          for coordSet in featCoordList:
                point.X = float(coordSet[0])*10
                point.Y = float(coordSet[1])*10
                array.add(point)


Any help is greatly appreciated.
J

Outcomes