GIScience / orstools-qgis-plugin

Plugin for QGIS with a set of tools to use openrouteservice API´s, based on openstreetmap
https://plugins.qgis.org/plugins/ORStools/
MIT License
92 stars 31 forks source link

Invalid coordinates for geocoding #59

Closed lewisdjl closed 5 years ago

lewisdjl commented 6 years ago

Hi Can someone explain why I'm getting the python error 'invalid coordinates for geo-referencing' please? I'm using an easting/northing such as 293427, 91642. The error message is below. i'm using OSM Tools 3.1 in QGIS 3.0.2 Thanks in advance for any help. David

An error has occurred while executing Python code:

ValueError: Your input coordinates are invalid for geocoding. Traceback (most recent call last): File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\urllib3\connection.py", line 141, in _new_conn (self.host, self.port), self.timeout, **extra_kw) File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\urllib3\util\connection.py", line 83, in create_connection raise err File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\urllib3\util\connection.py", line 73, in create_connection sock.connect(sa) TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen chunked=chunked) File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\urllib3\connectionpool.py", line 346, in _make_request self._validate_conn(conn) File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\urllib3\connectionpool.py", line 850, in _validate_conn conn.connect() File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\urllib3\connection.py", line 284, in connect conn = self._new_conn() File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\urllib3\connection.py", line 150, in _new_conn self, "Failed to establish a new connection: %s" % e) urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\requests\adapters.py", line 440, in send timeout=timeout File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen _stacktrace=sys.exc_info()[2]) File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\urllib3\util\retry.py", line 388, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.openrouteservice.org', port=443): Max retries exceeded with url: /geocoding?location=298938.05073099415%2C92780.57010551741&api_key=58d904a497c67e00015b45fc8bbc42b08cd34a23a92f5f00a69e3383 (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/Users/lewisd/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\geocode.py", line 17, in reverse_geocode response = client.request('/geocoding', params)['features'][0] File "C:/Users/lewisd/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\client.py", line 148, in request final_requests_kwargs) File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\requests\sessions.py", line 521, in get return self.request('GET', url, kwargs) File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\requests\sessions.py", line 508, in request resp = self.send(prep, send_kwargs) File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\requests\sessions.py", line 618, in send r = adapter.send(request, kwargs) File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\requests\adapters.py", line 508, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.openrouteservice.org', port=443): Max retries exceeded with url: /geocoding?location=298938.05073099415%2C92780.57010551741&api_key=58d904a497c67e00015b45fc8bbc42b08cd34a23a92f5f00a69e3383 (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/Users/lewisd/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\dialog.py", line 284, in _writeCoordinateLabel point) File "C:/Users/lewisd/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\geocode.py", line 19, in reverse_geocode raise ValueError("Your input coordinates are invalid for geocoding.") ValueError: Your input coordinates are invalid for geocoding.

Python version: 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] QGIS version: 3.0.2-Girona Girona, 307d082e3d

Python Path: C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python C:/Users/lewisd/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:/Users/lewisd/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins C:\Program Files\QGIS 3.0\bin\python36.zip C:\PROGRA~1\QGIS3~1.0\apps\Python36\DLLs C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib C:\Program Files\QGIS 3.0\bin C:\PROGRA~1\QGIS3~1.0\apps\Python36 C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\win32 C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\win32\lib C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\site-packages\Pythonwin C:/Users/lewisd/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:\Users\lewisd\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins C:\Users\lewisd\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins N:/Delivery - Contracting and BI/Information/Urgent Care/QGIS/Projects/MIU attendances

civil142 commented 6 years ago

From experience, I always use WGS 84 as this (and many other plugins done seem to work with other CRS - also ensure all CRS are matching and unload google maps if thats loaded in too.

nilsnolde commented 6 years ago

Hi, really sorry about this! I had an old geocoding endpoint in there which we deprecated a few days/weeks ago.. It's fixed now though in master (QGIS v3.x) and branch v2.1 (QGIS v2.x). Hope that helps...

It's uploaded to the plugin repo, should be approved by tmrw.

nilsnolde commented 6 years ago

Oh and you can use whatever CRS (or any CRS QgsCoordinateReferenceSystem knows of). Since a few releases, I actually implemented a datum transformator..

lewisdjl commented 6 years ago

Thankyou Nils, much appreciated

David Lewis Senior Information Specialist, Finance, Contracting and Business Intelligence

NHS Northern, Eastern and Western Devon Clinical Commissioning Group Direct Dial: 01392 675326| Email: david.lewis6@nhs.netmailto:david.lewis6@nhs.net NEW Devon CCG | 2nd Floor Main Building|County Hall |Topsham Road | Exeter |EX2 4QL [Description: Description: NHS2] Healthy people, living healthy lives, in healthy communities

From: Nils [mailto:notifications@github.com] Sent: 03 July 2018 22:59 To: nilsnolde/OSMtools Cc: LEWIS, David (NHS NORTHERN, EASTERN AND WESTERN DEVON CCG); Author Subject: Re: [nilsnolde/OSMtools] Invalid coordinates for geocoding (#59)

Oh and you can use whatever CRS (or any CRS QgsCoordinateReferenceSystem knows of). Since a few releases, I actually implemented a datum transformator..

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/nilsnolde/OSMtools/issues/59#issuecomment-402304292, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlcRML8wb7UT24w33LkzKH-OZNQpKW8Cks5uC-k4gaJpZM4UTSDf.


This message may contain confidential information. If you are not the intended recipient please inform the sender that you have received the message in error before deleting it. Please do not disclose, copy or distribute information in this e-mail or take any action in relation to its contents. To do so is strictly prohibited and may be unlawful. Thank you for your co-operation.

NHSmail is the secure email and directory service available for all NHS staff in England and Scotland. NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and other accredited email services.

For more information and to find out how you can switch, https://portal.nhs.net/help/joiningnhsmail

Blueridgesg commented 5 years ago

Hi, I'm new to QGIS learning my ways around. Found the nice routing tool in OSM Tools. It worked a couple times last week but failed with the following message since yesterday. I used "Routing", "foot-hiking", "shortest", picked both "Start Location(s)" and "End Location(s)", "From Map" with "Map Coordinates" both on/by a trail. Based on the discussion, it seems the problem has been resolved with the new release, but I'm using Rev 3.1.1. Any help is appreciated.


An error has occurred while executing Python code:

ValueError: Your input coordinates are invalid for geocoding. Traceback (most recent call last): File "C:/Users/Daniel/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\geocode.py", line 18, in reverse_geocode response = client.request('/geocode/reverse', params)['features'][0] File "C:/Users/Daniel/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\client.py", line 164, in request result = self._get_body(response) File "C:/Users/Daniel/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\client.py", line 196, in _get_body error['message']) TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/Users/Daniel/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\osm_tools.py", line 145, in run route.directions_calc() File "C:/Users/Daniel/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\directions.py", line 88, in directions_calc route_dict = self._selectInput() File "C:/Users/Daniel/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\directions.py", line 235, in _selectInput response_dict = geocode.reverse_geocode(self.client, *point_geom) File "C:/Users/Daniel/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\OSMtools\geocode.py", line 20, in reverse_geocode raise ValueError("Your input coordinates are invalid for geocoding.") ValueError: Your input coordinates are invalid for geocoding.

Python version: 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] QGIS version: 3.2.3-Bonn Bonn, 9b176802e5

Blueridgesg commented 5 years ago

I tried the same routing using the online service at https://maps.openrouteservice.org/. It works w/o any issue. I noticed the X, Y coordinate are reserved as compared to my QGIS project. The code (part of the plug-in) nilsnolde wrote shown at [https://github.com/nilsnolde/OSMtools/blob/master/geocode.py] is related to this. Checked the CRS and didn't seem to be the problem. What can cause this? Thanks.

nilsnolde commented 5 years ago

Hi, yes, we have a problem currently with our geocoding endpoints.. Specifically the /reverse endpoint. And OSM Tools is querying that in the background to extract info about city, street etc and map that to fields in the routing layer.

I'm really busy right now to fix that, so I can't take care of a hotfix for OSM tools right now. But it likely takes a couple of days. You can disable querying the reverse endpoint here. Likely have to alter a bit more code, but shouldn't be much.

In case, you can temporarily fix it, pls provide a PR on a new branch. Thx

nilsnolde commented 5 years ago

BTW, it only happens for the 'Map' button, routing from files should work. Although there's another bug, see workaround here

nilsnolde commented 5 years ago

I really need to fix this tool...

nilsnolde commented 5 years ago

@Blueridgesg, now it seems to work half the time.. Still not entirely resolved though. But if you try often enough, it will work after the 2nd or 3rd attempt..

Blueridgesg commented 5 years ago

@nilsnolde, thank you for the prompt reply. I tried playing with it today and it works (now), probably intermittent as you mentioned. I was using the Map Coordinates mode. Didn't seem to have luck using the From Layer mode. I created a simple shapfile layer, with Type set to Point. I added Name field on top of the default id field. Added a couple points on a trail to it, each with an unique name. I then use the From Layer mode. Selected the layer, picked Name from "Select Unique ID field" - What does this selection do? How is it related to selecting the From and To points? Upon hitting the confirm button the plugin runs w/o any error nor did it create the route like it does using the Map Coordinates mode. Thanks again for your work.

nilsnolde commented 5 years ago

@Blueridgesg our servers recovered 2 days ago. So you shouldn't have any problem now.. 'Select Unique ID' doesn't do much I think. Not sure anymore, but I believe I copy all properties from the original file anyways, so not necessarily a need for a uid field. Like I said, didn't look into this in ages. But I will before the end of the year:)

See this workraound for file layers (it's always worth to look through older issues BTW, esp. the ones with workarounds): #47

Blueridgesg commented 5 years ago

@nilsnolde thank you for looking into this. It works now.

I actually read the workaround at #47 but couldn’t figure out how “select the features” in the layer(s) works. I have a Point layer (shapfile) with a “Name” field. Two points are in this layer with “origin” and “desti” as the Name. How do I use the From Layer mode to route from origin to desti? Thanks.

nilsnolde commented 5 years ago

Should be fixed now. Proper transformation of CRS != 4326.

lewisdjl commented 5 years ago

Thanks!

David Lewis Senior Information Specialist, Finance, Contracting and Business Intelligence

NHS Northern, Eastern and Western Devon Clinical Commissioning Group Direct Dial: 01392 675326| Email: david.lewis6@nhs.netmailto:david.lewis6@nhs.net NEW Devon CCG | 2nd Floor Main Building|County Hall |Topsham Road | Exeter |EX2 4QL [Description: Description: NHS2] Healthy people, living healthy lives, in healthy communities

From: Nils [mailto:notifications@github.com] Sent: 22 November 2018 11:13 To: nilsnolde/OSMtools Cc: LEWIS, David (NHS NORTHERN, EASTERN AND WESTERN DEVON CCG); Author Subject: Re: [nilsnolde/OSMtools] Invalid coordinates for geocoding (#59)

Should be fixed now. Proper transformation of CRS != 4326.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/nilsnolde/OSMtools/issues/59#issuecomment-440997339, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlcRMOUBjOPhXMQ18MhRC4SzyWaiP69Oks5uxoa7gaJpZM4UTSDf.


This message may contain confidential information. If you are not the intended recipient please inform the sender that you have received the message in error before deleting it. Please do not disclose, copy or distribute information in this e-mail or take any action in relation to its contents. To do so is strictly prohibited and may be unlawful. Thank you for your co-operation.

NHSmail is the secure email and directory service available for all NHS staff in England and Scotland. NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and other accredited email services.

For more information and to find out how you can switch, https://portal.nhs.net/help/joiningnhsmail