Unable to call script into python
Question:
Below is the code that i am trying to run. I have a few polygon data to convert into longitude and latitude. ‘SVY21()’ is the script i imported to convert my polygon data
# Initialization
>>> import SVY21()
>>> cv = SVY21()
# Computing SVY21 from Lat/Lon
>>> (lat, lon) = (1.2949192688485278, 103.77367436885834)
>>> (N, E) = cv.computeSVY21(lat, lon)
>>> (N, E)
(30811.26429645264, 21362.157043860374)
# Computing Lat/Lon from SVY21
>>> (lat, lon) = cv.computeLatLon(N, E)
>>> (lat, lon)
(1.2949192688483109, 103.77367436887495)
However, the error that i got is
line 4, in
cv = SVY21()
TypeError: ‘module’ object is not callable.
Sorry if this is a stupid question. I am not very good.
P.S both script ‘SVY21’ and main.py is in the same folder.
Answers:
You can’t use parenthesis in the import statements. Also you import a whole module, you probably want to use a function from that module.
If this is the source code you’re trying to use:
https://github.com/cgcai/SVY21/blob/master/Python/SVY21.py
then you probably want to change the import statement to:
from SVY21 import SVY21
Below is the code that i am trying to run. I have a few polygon data to convert into longitude and latitude. ‘SVY21()’ is the script i imported to convert my polygon data
# Initialization
>>> import SVY21()
>>> cv = SVY21()
# Computing SVY21 from Lat/Lon
>>> (lat, lon) = (1.2949192688485278, 103.77367436885834)
>>> (N, E) = cv.computeSVY21(lat, lon)
>>> (N, E)
(30811.26429645264, 21362.157043860374)
# Computing Lat/Lon from SVY21
>>> (lat, lon) = cv.computeLatLon(N, E)
>>> (lat, lon)
(1.2949192688483109, 103.77367436887495)
However, the error that i got is
line 4, in
cv = SVY21()
TypeError: ‘module’ object is not callable.
Sorry if this is a stupid question. I am not very good.
P.S both script ‘SVY21’ and main.py is in the same folder.
You can’t use parenthesis in the import statements. Also you import a whole module, you probably want to use a function from that module.
If this is the source code you’re trying to use:
https://github.com/cgcai/SVY21/blob/master/Python/SVY21.py
then you probably want to change the import statement to:
from SVY21 import SVY21