How do I remove the filename prefix in the attribute table of a kml file when exporting a kml file using sf package in R?

28 views Asked by At

After exporting a layer from arc, I import into R using the sf library. I join some data to this object. I rename the fields of the object (called "shape"):

names(shape) <- c('RelationshipNumber', 'Bed', 'HarvestBed', "BogName", 'Acres', 'Variety', 'ProdStatus', 'PlantYear', 'HarvestYear', 'MapPage', 'Contractname', 'Longitude', 'Latitude', 'geometry')  

I then export using

st_write(shape, driver = 'kml', dsn = 'test.kml')

I open the resulting kml file in google earth. When inspecting a polygon, the attribute table has 'test:' prefixed to all attributes. 'test' is the name I gave to st_write in order to create the kml file. I am guessing it is prefixing the attributes with the layer name.

How can I remove this very annoying prefix?

If I import the kml into Arc, I do not see the prefix. I then export it as a kmz from Arc and the attribute prefix is gone. It seems like this would suggest that the prefix is related to whatever schema is used by st_write.

0

There are 0 answers