1

I need to export data from a file gdb to a shapefile or PostGIS format, run a script that will create one-sided buffers in QGIS for the sides of streets whenever a point feature is found on that street, and then import the resultant polygons back to the original file gdb. Can this be reasonably done with pyqgis calling the Single Sided Buffers (and offset lines) for lines tool in the GDAL/OGR geoprocessing library? My sample code thus far is just trying to import the qgis module but my citrix vdi won't allow me to bring it in when using PythonWin, although it works in the QGIS python command window.

Here is my attempt at trying to import the qgis module:

>>> import qgis
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ImportError: No module named qgis
>>> from qgis.core
Traceback (  File "<interactive input>", line 1
    from qgis.core
                 ^
SyntaxError: invalid syntax
>>> import qgis.core
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ImportError: No module named qgis.core

>>> import os
>>> import sys
>>> x = sys.path.append(r'C:/PROGRA~2/QGIS2~1.14/apps/qgis-ltr/./python\\qgis\\__init__.py')
>>> x
>>> os.listdir(x)
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
TypeError: coercing to Unicode: need string or buffer, NoneType foundfrom x

>>> from x import qgis-ltr
Traceback (  File "<interactive input>", line 1
    from x import qgis-ltr
                      ^
SyntaxError: invalid syntax
>>> import x
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ImportError: No module named x
>>> x = r"C:\Program Files (x86)\QGIS 2.14\apps\qgis-ltr\python\qgis"
>>> sys.path.append(x)
>>> import qgis
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ImportError: No module named qgis
>>> os.listdir(x)
['analysis', 'core', 'gui', 'networkanalysis', 'PyQt', 'testing', 'user.py', 'utils.py', '_analysis.lib', '_analysis.pyd', '_core.lib', '_core.pyd', '_gui.lib', '_gui.pyd', '_networkanalysis.lib', '_networkanalysis.pyd', '__init__.py']
>>> x = r"C:\Program Files (x86)\QGIS 2.14\apps\qgis-ltr\python\qgis\core"
>>> os.listdir(x)
['contextmanagers.py', '__init__.py']
  • A question asking about code should include an attempt at code, and details of what happens when you try it. Please edit your question to show us what you've got so far. – Midavalo Mar 17 '17 at 19:36
  • I have edited the post and included what little code I have. Unfortunately, I can't import the qgis module to provide more code – geoJshaun Mar 17 '17 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.