GeoDaCenter / spatial_access

https://spatial.uchicago.edu
37 stars 11 forks source link

ValueError: Latitude must be in the [-90; 90] range. #56

Closed ifarah closed 5 years ago

ifarah commented 5 years ago

Hello Logan, I believe the code is throwing this error for latitudes, reading from the longitude column. (see error below) I specified latitudes as coord_y and longitude as coord_x. coord_x is indeed ranging [-91,90], but coord_y is ranging [36,40]

Screen Shot 2019-04-23 at 11 29 48 AM Screen Shot 2019-04-23 at 11 30 03 AM

I'm also copying and pasting the error just in case it's easier for you.

INFO:spatial_access.p2p:Total number of rows in the dataset: 119 /usr/local/lib/python3.6/site-packages/geopy/point.py:81: 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. UserWarning)

ValueError Traceback (most recent call last)

in () ----> 1 matrix.process() /usr/local/lib/python3.6/site-packages/spatial_access-0.1.6.13-py3.6-macosx-10.13-x86_64.egg/spatial_access/p2p.py in process(self) 461 self.network_type, self.epsilon) 462 --> 463 self.prefetch_network() 464 465 is_symmetric = self.secondary_input is None and self.network_type is 'drive' /usr/local/lib/python3.6/site-packages/spatial_access-0.1.6.13-py3.6-macosx-10.13-x86_64.egg/spatial_access/p2p.py in prefetch_network(self) 440 self.secondary_data, 441 self.secondary_input is not None, --> 442 self.epsilon) 443 444 def clear_cache(self): /usr/local/lib/python3.6/site-packages/spatial_access-0.1.6.13-py3.6-macosx-10.13-x86_64.egg/spatial_access/NetworkInterface.py in load_network(self, primary_data, secondary_data, secondary_input, epsilon) 157 self._try_create_cache() 158 self._get_bbox(primary_data, secondary_data, --> 159 secondary_input, epsilon) 160 if self._network_exists(): 161 filename = self.get_filename() /usr/local/lib/python3.6/site-packages/spatial_access-0.1.6.13-py3.6-macosx-10.13-x86_64.egg/spatial_access/NetworkInterface.py in _get_bbox(self, primary_data, secondary_data, secondary_input, epsilon) 100 self.bbox = [lon_min, lat_min, lon_max, lat_max] 101 if self.area_threshold: --> 102 approx_area = self._approximate_bbox_area() 103 if approx_area > self.area_threshold: 104 if self.logger: /usr/local/lib/python3.6/site-packages/spatial_access-0.1.6.13-py3.6-macosx-10.13-x86_64.egg/spatial_access/NetworkInterface.py in _approximate_bbox_area(self) 56 lower_right_point = (self.bbox[3], self.bbox[0]) 57 upper_left_point = (self.bbox[1], self.bbox[2]) ---> 58 lower_edge = distance.distance(lower_left_point, lower_right_point).km 59 left_edge = distance.distance(lower_left_point, upper_left_point).km 60 area = lower_edge * left_edge /usr/local/lib/python3.6/site-packages/geopy/distance.py in __init__(self, *args, **kwargs) 382 kwargs.pop('iterations', 0) 383 major, minor, f = self.ELLIPSOID # pylint: disable=W0612 --> 384 super(geodesic, self).__init__(*args, **kwargs) 385 386 def set_ellipsoid(self, ellipsoid): /usr/local/lib/python3.6/site-packages/geopy/distance.py in __init__(self, *args, **kwargs) 160 elif len(args) > 1: 161 for a, b in util.pairwise(args): --> 162 kilometers += self.measure(a, b) 163 164 kilometers += units.kilometers(**kwargs) /usr/local/lib/python3.6/site-packages/geopy/distance.py in measure(self, a, b) 403 # Call geographiclib routines for measure and destination 404 def measure(self, a, b): --> 405 a, b = Point(a), Point(b) 406 lat1, lon1 = a.latitude, a.longitude 407 lat2, lon2 = b.latitude, b.longitude /usr/local/lib/python3.6/site-packages/geopy/point.py in __new__(cls, latitude, longitude, altitude) 169 ) 170 else: --> 171 return cls.from_sequence(seq) 172 173 if single_arg: /usr/local/lib/python3.6/site-packages/geopy/point.py in from_sequence(cls, seq) 408 raise ValueError('When creating a Point from sequence, it ' 409 'must not have more than 3 items.') --> 410 return cls(*args) 411 412 @classmethod /usr/local/lib/python3.6/site-packages/geopy/point.py in __new__(cls, latitude, longitude, altitude) 181 182 latitude, longitude, altitude = \ --> 183 _normalize_coordinates(latitude, longitude, altitude) 184 185 self = super(Point, cls).__new__(cls) /usr/local/lib/python3.6/site-packages/geopy/point.py in _normalize_coordinates(latitude, longitude, altitude) 80 '(latitude, longitude) or (y, x) in Cartesian terms.', 81 UserWarning) ---> 82 raise ValueError('Latitude must be in the [-90; 90] range.') 83 84 if abs(longitude) > 180: ValueError: Latitude must be in the [-90; 90] range.
jkoschinsky commented 5 years ago

this would be great if you could address asap if you have time, then we can run results for a Thursday deadline. Thx!

lmnoel commented 5 years ago

Working on this now

lmnoel commented 5 years ago

do you have a sample of this data readily available?

lmnoel commented 5 years ago

fixed

geo-pal commented 3 years ago

Hey Irene,

I'm experiencing the same error (lat [90,-90]) with my project,

how did you fix this issue? This would be great if you share. Thanks!

jkoschinsky commented 3 years ago

Hi, Could you check if you're using projected coordinates that are out of the [-90;90] range instead of lat-lon? Thanks, Julia

https://spatial-data-science-conference.com/


From: palanicres100 notifications@github.com Sent: Saturday, February 27, 2021 7:12 PM To: GeoDaCenter/spatial_access spatial_access@noreply.github.com Cc: Julia Koschinsky jkoschinsky@uchicago.edu; Comment comment@noreply.github.com Subject: Re: [GeoDaCenter/spatial_access] ValueError: Latitude must be in the [-90; 90] range. (#56)

Hey Irene,

I'm experiencing the same error (lat [90,-90]) with my project,

how did you fix this issue? This would be great if you share. Thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/GeoDaCenter/spatial_access/issues/56#issuecomment-787214426, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADILY76JNLBGQL3AS62MMLTTBGKARANCNFSM4HH3IRAA.