Round-trip the data through a flat projection, ideally one which preserves area, such as Equal Area Cylindrical ('+proj=cea'):
This projects the shapes onto a flat surface, which can then be used to find the centroid, and then converts back into the original coordinate system.
Choosing a projection
Note that ...
Figured it out!
The code was reading the column names easting and northing, which is why it was throwing me the error. Instead I had to skip over the first line by using
line_count += 1
if self.device_type == 'BNG':
If you only have two possible CRS inputs, and one is a projected system in meters whereas the other one is in decimal degrees, have you thought about using a regex pattern to determine whether the input is one or the other?
Here's how you would detect a decimal degree input. Feel free to update the pattern if your input is DMS or something else. Constructing ...