Friday 29 April 2016

Accessing GPS from QGIS 2.14.1/Python 2.7 /Windows10


I would like to access the device described at QGIS live GPS tracking /recommended hardware (GPS USB stick) via QGIS/Python.


A gps module does't seem to be part of the standard installation of python 2.7 coming with QGIS 2.14.1 installed via OSGeo4W installer (allthough i read somewhere that gps module ist part of the standard Python installation).


Platform: Windows10


>>> import gps
Traceback (most recent call last):
File "", line 1, in

ImportError: No module named gps

However, trying to install some related modules (gps, gps3, gpsd, GPSReader) via OSGeo4W shell gives me errors like


C:\Users\Jochen\Downloads>pip install gps3
Collecting gps3
C:\OSGeo4W64\apps\Python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
C:\OSGeo4W64\apps\Python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Could not find a version that satisfies the requirement gps3 (from versions: )

No matching distribution found for gps3

But


C:\Users\Jochen\Downloads>pip search gps3
C:\OSGeo4W64\apps\Python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
C:\OSGeo4W64\apps\Python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
gps3 (0.1a) - Python2.7- Python3.4 gpsd interface


lists the gps3 module for example.


I simply need lat/lon from gps, which modules to install and how? Or any other hints of how to achieve this?


Some things I found in this context:


https://trac.osgeo.org/osgeo4w/wiki/ExternalPythonPackages


How to install 3rd party python libraries for QGIS on Windows?


https://gist.github.com/wolfg1969/4653340



Answer



A little more research (google for 'qgis python access gps') brougth the solution, once more as simple as obvious, and with no additional python modules to be installed.


I found this:


http://imasdemase.com/programacion-2/get-gps-info-qgis-python-console/



My spanish is not the best (if any), but i understand the code mentioned which works fine:


connectionRegistry = QgsGPSConnectionRegistry().instance()
connectionList = connectionRegistry.connectionList()
GPSInfo = connectionList[0].currentGPSInformation()
lon = GPSInfo.longitude
lat = GPSInfo.latitude

that's all.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...