Closed Bachirou06 closed 1 month ago
Hi,
Thank you for emailing.
The error is saying that the Latitude must be between -90 and 90.
From the error snippet that you have sent, I am not able to see which line in the code the error is coming from, but it could help to check your parameter file where you have your latitude stored.
Many thanks, Samiyha
From: DJIBO BOUBE Bachirou @.> Sent: 10 October 2024 23:20 To: ClimateCompatibleGrowth/GeoH2 @.> Cc: Subscribed @.***> Subject: [ClimateCompatibleGrowth/GeoH2] optimize_transport_and_conversion.py error (Issue #20)
Hi all, I am novice using GeoH2, i am running an analysis for given country. I came accros an error related to the coordinate normalization in geodesic which seems to be depreciated. I will be grateful with some hint. Below is the error
for i in range(len(hexagon)):
poly = shapely.wkt.loads(str(hexagon['geometry'][i])) center = poly.centroid demand_coords = (demand_center_list.loc[d,'Lat [deg]'], demand_center_list.loc[d,'Lon [deg]']) hexagon_coords = (center.y, center.x) dist = geopy.distance.geodesic(demand_coords, hexagon_coords).km
distance_to_demand[i] = dist
…………………………… …………… …… …. .. 187 latitude, longitude, altitude = --> 188 _normalize_coordinates(latitude, longitude, altitude) 190 self = super().new(cls) 191 self.latitude = latitude
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:74http://localhost:8892/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/point.py#line=73, in _normalize_coordinates(latitude, longitude, altitude) 66 if abs(latitude) > 90: 67 warnings.warn('Latitude normalization has been prohibited in the newer ' 68 'versions of geopy, because the normalized value happened ' 69 'to be on a different pole, which is probably not what was ' (...) 72 '(latitude, longitude) or (y, x) in Cartesian terms.', 73 UserWarning, stacklevel=3) ---> 74 raise ValueError('Latitude must be in the [-90; 90] range.') 76 if abs(longitude) > 180: 77 # Longitude normalization is pretty straightforward and doesn't seem 78 # to be error-prone, so there's nothing to complain about. 79 longitude = _normalize_angle(longitude, 180.0)
ValueError: Latitude must be in the [-90; 90] range.
— Reply to this email directly, view it on GitHubhttps://github.com/ClimateCompatibleGrowth/GeoH2/issues/20, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BKKL4AWEGDMJCYOOQWGCKDTZ234RFAVCNFSM6AAAAABPXXFOACVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU3TSOJVG43DENI. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Thanks for your prompte response: The error is on the line 115 115 dist = geopy.distance.geodesic(demand_coords, hexagon_coords).km
i have even shift back to the geopy 2.0 instead of 2.4.1 The country bbox is: 'NE': ('Niger', (0.295646396495, 11.6601671412, 15.9032466977, 23.4716684026)), Kindly receive below further explanation.
ValueError Traceback (most recent call last) Cell In[15], line 115 113 #hexagon_coords = (center.x, center.y) 114 hexagon_coords = (center.y, center.x) --> 115 dist = geopy.distance.geodesic(demand_coords, hexagon_coords).km 117 distance_to_demand[i] = dist 119 #!!! maybe this is the place to set a restriction based on distance to demand center-- for all hexagons with a distance below some cutoff point 120 # label demand location under consideration
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\distance.py:418, in geodesic.init(self, *args, *kwargs) 416 self.set_ellipsoid(kwargs.pop('ellipsoid', 'WGS-84')) 417 major, minor, f = self.ELLIPSOID --> 418 super().init(args, **kwargs)
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\distance.py:201, in Distance.init(self, *args, kwargs) 199 elif len(args) > 1: 200 for a, b in util.pairwise(args): --> 201 kilometers += self.measure(a, b) 203 kilometers += units.kilometers(kwargs) 204 self.__kilometers = kilometers
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\distance.py:438, in geodesic.measure(self, a, b) 437 def measure(self, a, b): --> 438 a, b = Point(a), Point(b) 439 _ensure_same_altitude(a, b) 440 lat1, lon1 = a.latitude, a.longitude
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:174, in Point.new(cls, latitude, longitude, altitude) 170 raise TypeError( 171 "Failed to create Point instance from %r." % (arg,) 172 ) 173 else: --> 174 return cls.from_sequence(seq) 176 if single_arg: 177 raise ValueError( 178 'A single number has been passed to the Point ' 179 'constructor. This is probably a mistake, because ' (...) 183 'to get rid of this error.' 184 )
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:471, in Point.from_sequence(cls, seq) 468 if len(args) > 3: 469 raise ValueError('When creating a Point from sequence, it ' 470 'must not have more than 3 items.') --> 471 return cls(*args)
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:187, in Point.new(cls, latitude, longitude, altitude) 176 if single_arg: 177 raise ValueError( 178 'A single number has been passed to the Point ' 179 'constructor. This is probably a mistake, because ' (...) 183 'to get rid of this error.' 184 ) 186 latitude, longitude, altitude = \ --> 187 _normalize_coordinates(latitude, longitude, altitude) 189 self = super().new(cls) 190 self.latitude = latitude
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:74, in _normalize_coordinates(latitude, longitude, altitude) 66 if abs(latitude) > 90: 67 warnings.warn('Latitude normalization has been prohibited in the newer ' 68 'versions of geopy, because the normalized value happened ' 69 'to be on a different pole, which is probably not what was ' (...) 72 '(latitude, longitude) or (y, x) in Cartesian terms.', 73 UserWarning, stacklevel=3) ---> 74 raise ValueError('Latitude must be in the [-90; 90] range.') 76 if abs(longitude) > 180: 77 # Longitude normalization is pretty straightforward and doesn't seem 78 # to be error-prone, so there's nothing to complain about. 79 longitude = _normalize_angle(longitude, 180.0)
ValueError: Latitude must be in the [-90; 90] range.
Thank you for sharing more information.
Can you check your Parameters/demand_parameters.xlsx file and share your latitude and longitude values with me please.
Many thanks, Samiyha
From: DJIBO BOUBE Bachirou @.> Sent: 11 October 2024 11:04 To: ClimateCompatibleGrowth/GeoH2 @.> Cc: Samiyha Naqvi @.>; Comment @.> Subject: Re: [ClimateCompatibleGrowth/GeoH2] optimize_transport_and_conversion.py error (Issue #20)
Thanks for your prompte response: The error is on the line 115 115 dist = geopy.distance.geodesic(demand_coords, hexagon_coords).km
i have even shift back to the geopy 2.0 instead of 2.4.1
Kindly receive below further explanation.
C:\Users\hp\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:471: UserWarning: Latitude normalization has been prohibited in the newer versions of geopy, because the normalized value happened to be on a different pole, which is probably not what was meant. If you pass coordinates as positional args, please make sure that the order is (latitude, longitude) or (y, x) in Cartesian terms. return cls(*args)
ValueError Traceback (most recent call last) Cell In[15], line 115 113 #hexagon_coords = (center.x, center.y) 114 hexagon_coords = (center.y, center.x) --> 115 dist = geopy.distance.geodesic(demand_coords, hexagon_coords).km 117 distance_to_demand[i] = dist 119 #!!! maybe this is the place to set a restriction based on distance to demand center-- for all hexagons with a distance below some cutoff point 120 # label demand location under consideration
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\distance.py:418http://localhost:8957/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/distance.py#line=417, in geodesic.init(self, *args, *kwargs) 416 self.set_ellipsoid(kwargs.pop('ellipsoid', 'WGS-84')) 417 major, minor, f = self.ELLIPSOID --> 418 super().init(args, **kwargs)
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\distance.py:201http://localhost:8957/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/distance.py#line=200, in Distance.init(self, *args, kwargs) 199 elif len(args) > 1: 200 for a, b in util.pairwise(args): --> 201 kilometers += self.measure(a, b) 203 kilometers += units.kilometers(kwargs) 204 self.__kilometers = kilometers
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\distance.py:438http://localhost:8957/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/distance.py#line=437, in geodesic.measure(self, a, b) 437 def measure(self, a, b): --> 438 a, b = Point(a), Point(b) 439 _ensure_same_altitude(a, b) 440 lat1, lon1 = a.latitude, a.longitude
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:174http://localhost:8957/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/point.py#line=173, in Point.new(cls, latitude, longitude, altitude) 170 raise TypeError( 171 "Failed to create Point instance from %r." % (arg,) 172 ) 173 else: --> 174 return cls.from_sequence(seq) 176 if single_arg: 177 raise ValueError( 178 'A single number has been passed to the Point ' 179 'constructor. This is probably a mistake, because ' (...) 183 'to get rid of this error.' 184 )
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:471http://localhost:8957/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/point.py#line=470, in Point.from_sequence(cls, seq) 468 if len(args) > 3: 469 raise ValueError('When creating a Point from sequence, it ' 470 'must not have more than 3 items.') --> 471 return cls(*args)
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:187http://localhost:8957/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/point.py#line=186, in Point.new(cls, latitude, longitude, altitude) 176 if single_arg: 177 raise ValueError( 178 'A single number has been passed to the Point ' 179 'constructor. This is probably a mistake, because ' (...) 183 'to get rid of this error.' 184 ) 186 latitude, longitude, altitude = --> 187 _normalize_coordinates(latitude, longitude, altitude) 189 self = super().new(cls) 190 self.latitude = latitude
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:74http://localhost:8957/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/point.py#line=73, in _normalize_coordinates(latitude, longitude, altitude) 66 if abs(latitude) > 90: 67 warnings.warn('Latitude normalization has been prohibited in the newer ' 68 'versions of geopy, because the normalized value happened ' 69 'to be on a different pole, which is probably not what was ' (...) 72 '(latitude, longitude) or (y, x) in Cartesian terms.', 73 UserWarning, stacklevel=3) ---> 74 raise ValueError('Latitude must be in the [-90; 90] range.') 76 if abs(longitude) > 180: 77 # Longitude normalization is pretty straightforward and doesn't seem 78 # to be error-prone, so there's nothing to complain about. 79 longitude = _normalize_angle(longitude, 180.0)
ValueError: Latitude must be in the [-90; 90] range.
— Reply to this email directly, view it on GitHubhttps://github.com/ClimateCompatibleGrowth/GeoH2/issues/20#issuecomment-2407074481, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BKKL4ASV2I7R2DOXQLM47VDZ26PBVAVCNFSM6AAAAABPXXFOACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBXGA3TINBYGE. You are receiving this because you commented.Message ID: @.***>
I've just realised that you might be using an older version of the repo. Have you pulled from the repo recently to update your version?
Please try the below when you are in the GeoH2 folder (if you haven't updated it since September 25th):
git pull origin main
And then please read the Readme as we have updated the code. Remember to update the environment with the new environment.yaml file.
If this is not the case, please could you send a screenshot(s) of the full error in your terminal/console and the contents of your hexagons_withcountry{COUNTRY ISO CODE}.geojson file, as this might be where the latitude is above 90 or below -90.
Many thanks, Samiyha
From: DJIBO BOUBE Bachirou @.> Sent: 11 October 2024 17:02 To: ClimateCompatibleGrowth/GeoH2 @.> Cc: Samiyha Naqvi @.>; Comment @.> Subject: Re: [ClimateCompatibleGrowth/GeoH2] optimize_transport_and_conversion.py error (Issue #20)
Thank you for sharing more information. Can you check your Parameters/demand_parameters.xlsx file and share your latitude and longitude values with me please. Many thanks, Samiyha Lat [deg] : 13, Lon[deg]: 2
image.png (view on web)https://github.com/user-attachments/assets/9ebfce10-fd16-4b25-8387-e890a98af1aa
… ____ From: DJIBO BOUBE Bachirou @.> Sent: 11 October 2024 11:04 To: ClimateCompatibleGrowth/GeoH2 @.> Cc: Samiyha Naqvi @.>; Comment @.> Subject: Re: [ClimateCompatibleGrowth/GeoH2] optimize_transport_and_conversion.py error (Issue #20https://github.com/ClimateCompatibleGrowth/GeoH2/issues/20) Thanks for your prompte response: The error is on the line 115 115 dist = geopy.distance.geodesic(demand_coords, hexagon_coords).km i have even shift back to the geopy 2.0 instead of 2.4.1 Kindly receive below further explanation. C:\Users\hp\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:471: UserWarning: Latitude normalization has been prohibited in the newer versions of geopy, because the normalized value happened to be on a different pole, which is probably not what was meant. If you pass coordinates as positional args, please make sure that the order is (latitude, longitude) or (y, x) in Cartesian terms. return cls(args) ValueError Traceback (most recent call last) Cell In[15], line 115 113 #hexagon_coords = (center.x, center.y) 114 hexagon_coords = (center.y, center.x) --> 115 dist = geopy.distance.geodesic(demand_coords, hexagon_coords).km 117 distance_to_demand[i] = dist 119 #!!! maybe this is the place to set a restriction based on distance to demand center-- for all hexagons with a distance below some cutoff point 120 # label demand location under consideration File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\distance.py:418http://localhost:8957/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/distance.py#line=417, in geodesic.init(self, args, kwargs) 416 self.set_ellipsoid(kwargs.pop('ellipsoid', 'WGS-84')) 417 major, minor, f = self.ELLIPSOID --> 418 super().init(*args, *kwargs) File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\distance.py:201http://localhost:8957/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/distance.py#line=200, in Distance.init(self, args, kwargs) 199 elif len(args) > 1: 200 for a, b in util.pairwise(args): --> 201 kilometers += self.measure(a, b) 203 kilometers += units.kilometers(kwargs) 204 self.__kilometers = kilometers File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\distance.py:438http://localhost:8957/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/distance.py#line=437, in geodesic.measure(self, a, b) 437 def measure(self, a, b): --> 438 a, b = Point(a), Point(b) 439 _ensure_same_altitude(a, b) 440 lat1, lon1 = a.latitude, a.longitude File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:174http://localhost:8957/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/point.py#line=173, in Point.new(cls, latitude, longitude, altitude) 170 raise TypeError( 171 "Failed to create Point instance from %r." % (arg,) 172 ) 173 else: --> 174 return cls.from_sequence(seq) 176 if single_arg: 177 raise ValueError( 178 'A single number has been passed to the Point ' 179 'constructor. This is probably a mistake, because ' (...) 183 'to get rid of this error.' 184 ) File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:471http://localhost:8957/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/point.py#line=470, in Point.from_sequence(cls, seq) 468 if len(args) > 3: 469 raise ValueError('When creating a Point from sequence, it ' 470 'must not have more than 3 items.') --> 471 return cls(args) File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:187http://localhost:8957/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/point.py#line=186, in Point.new(cls, latitude, longitude, altitude) 176 if single_arg: 177 raise ValueError( 178 'A single number has been passed to the Point ' 179 'constructor. This is probably a mistake, because ' (...) 183 'to get rid of this error.' 184 ) 186 latitude, longitude, altitude = --> 187 _normalize_coordinates(latitude, longitude, altitude) 189 self = super().new(cls) 190 self.latitude = latitude File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:74http://localhost:8957/lab/tree/~/AppData/Local/miniconda3/envs/geoh2/lib/site-packages/geopy/point.py#line=73, in _normalize_coordinates(latitude, longitude, altitude) 66 if abs(latitude) > 90: 67 warnings.warn('Latitude normalization has been prohibited in the newer ' 68 'versions of geopy, because the normalized value happened ' 69 'to be on a different pole, which is probably not what was ' (...) 72 '(latitude, longitude) or (y, x) in Cartesian terms.', 73 UserWarning, stacklevel=3) ---> 74 raise ValueError('Latitude must be in the [-90; 90] range.') 76 if abs(longitude) > 180: 77 # Longitude normalization is pretty straightforward and doesn't seem 78 # to be error-prone, so there's nothing to complain about. 79 longitude = _normalize_angle(longitude, 180.0) ValueError: Latitude must be in the [-90; 90] range. — Reply to this email directly, view it on GitHub<#20 (comment)https://github.com/ClimateCompatibleGrowth/GeoH2/issues/20#issuecomment-2407074481>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BKKL4ASV2I7R2DOXQLM47VDZ26PBVAVCNFSM6AAAAABPXXFOACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBXGA3TINBYGE. You are receiving this because you commented.Message ID: @.>
— Reply to this email directly, view it on GitHubhttps://github.com/ClimateCompatibleGrowth/GeoH2/issues/20#issuecomment-2407708592, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BKKL4ASEOREJOIIWOHR3R5DZ27ZAPAVCNFSM6AAAAABPXXFOACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBXG4YDQNJZGI. You are receiving this because you commented.Message ID: @.***>
Hi @samiyhanaqvi,
I'm sorry for not getting back to you sooner, but I'm using the two versions. The current issue is related to the first version I am still exploring the new versions I will come back for further information regarding.
Thanks for reaching out.
Hi @samiyhanaqvi
This what i got as error, i have even the system to linux:
(geoh2s) bachirou@djibo:~/GeoH2-main_new_NE$ snakemake -j 1 Resources/hex_transport_NE.geojson Building DAG of jobs... Using shell: /bin/bash Provided cores: 1 (use --cores to define parallelism) Rules claiming more threads will be scaled down. Job stats: job count
optimize_transport_and_conversion 1 total 1
Select jobs to execute...
[Thu Oct 24 09:01:53 2024] rule optimize_transport_and_conversion: input: Data/hexagons_with_country_NE.geojson, Parameters/technology_parameters.xlsx, Parameters/demand_parameters.xlsx, Parameters/country_parameters.xlsx, Parameters/conversion_parameters.xlsx, Parameters/transport_parameters.xlsx, Parameters/pipeline_parameters.xlsx output: Resources/hex_transport_NE.geojson jobid: 0 reason: Missing output files: Resources/hex_transport_NE.geojson wildcards: country=NE resources: tmpdir=/tmp
Traceback (most recent call last):
File "/home/bachirou/GeoH2-main_new_NE/.snakemake/scripts/tmp2uj6l_u0.optimize_transport_and_conversion.py", line 57, in
RuleException: CalledProcessError in file /home/bachirou/GeoH2-main_new_NE/Snakefile, line 55: Command 'set -euo pipefail; /home/bachirou/miniconda3/envs/geoh2s/bin/python3.10 /home/bachirou/GeoH2-main_new_NE/.snakemake/scripts/tmp2uj6l_u0.optimize_transport_and_conversion.py' returned non-zero exit status 1. File "/home/bachirou/GeoH2-main_new_NE/Snakefile", line 55, in __rule_optimize_transport_and_conversion File "/home/bachirou/miniconda3/envs/geoh2s/lib/python3.10/concurrent/futures/thread.py", line 58, in run Shutting down, this might take some time. Exiting because a job execution failed. Look above for error message Complete log: .snakemake/log/2024-10-24T090153.559794.snakemake.log
Thank you for sharing this.
The error seems to be with the country parameters excel file. I would recommend checking that the format of the file is like the example file we have in the repo. If that's fine, you can try opening the file and "save as" an excel workbook as it could be in a different format, but with the same file extension.
How are you finding using the up-to-date software?
Hi Thanks a lot for the support @samiyhanaqvi. I have been able to find out the issue and correct. I am impressed by the flexibility of the updated version of the Geoh2 and the use of snakemake for running the code easily. Many thanks to the CCG team, you did amazing work. Keep it going
No worries. I am going to close this issue now.
Hi all, I am novice using GeoH2, i am running an analysis for given country. I came accros an error related to the coordinate normalization in geodesic which seems to be depreciated. I will be grateful with some hint. Below is the error
geopy 2.4.1 pyhd8ed1ab_1 conda-forge geos 3.11.0 h39d44d4_0 conda-forge
for i in range(len(hexagon)):
calculate distance to demand for each hexagon
…………………………… …………… …… …. .. 187 latitude, longitude, altitude = \ --> 188 _normalize_coordinates(latitude, longitude, altitude) 190 self = super().new(cls) 191 self.latitude = latitude
File ~\AppData\Local\miniconda3\envs\geoh2\lib\site-packages\geopy\point.py:74, in _normalize_coordinates(latitude, longitude, altitude) 66 if abs(latitude) > 90: 67 warnings.warn('Latitude normalization has been prohibited in the newer ' 68 'versions of geopy, because the normalized value happened ' 69 'to be on a different pole, which is probably not what was ' (...) 72 '(latitude, longitude) or (y, x) in Cartesian terms.', 73 UserWarning, stacklevel=3) ---> 74 raise ValueError('Latitude must be in the [-90; 90] range.') 76 if abs(longitude) > 180: 77 # Longitude normalization is pretty straightforward and doesn't seem 78 # to be error-prone, so there's nothing to complain about. 79 longitude = _normalize_angle(longitude, 180.0)
ValueError: Latitude must be in the [-90; 90] range.