I am dealing with a very similar situation as described at:

rgdal::writeOGR collision in column names results in NULL data

I have an sf object with duplicate field names (in a case-insensitive way). Coercing to sp with as(foo, "Spatial") does not do any sanitizing and this breaks downstream processing.

The errors I get are variously:

ERROR: Cannot insert new row: insert into foo values ( 1, 55800, )

Failed to create feature

Is there an automated solution other than manually checking for dups and renaming?


I would try with data janitor's function clean_names()

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.