I am converting coordinates to another format, but there was an error
longitude = (lon - 4294967295) / 6356752.3142 * (180/math.pi)
unsupported operand type(s) for -: 'list' and 'int'
I will be grateful for advice
CodePudding user response:
If lon is a list, rather than a numpy array, you can't perform subtraction directly. List comprehension would do it,
longitude = [(l - 4294967295) / 6356752.3142 * (180/math.pi) for l in lon]
which iterates through lon and applies the proper arithmetic on the iterates. Otherwise, using numpy, you can do it directly
import numpy as np
lon = np.array(lon)
longitude = (lon - 4294967295) / 6356752.3142 * (180/math.pi)
CodePudding user response:
You can't perform a mathematical operation like subtraction on a list AKA an iterable type and an integer. You're trying to do:
[0,1,2,3,..,n] - 4294967295
What you might have meant is:
(lon[i] - 4294967295)
Where i is the index number for whichever value of the list you wanted.
CodePudding user response:
Try just converting your lon from a list (which doesn't support arithmetic operations like , -, etc.) to a numpy array (which does support arithmetic operations):
lon = np.array(lon)
longitude = (lon - 4294967295) / 6356752.3142 * (180/math.pi)
