1

I am trying to buffer points from a FileGDB in a PyQGIS script. I setup my environment with the following batch file and run the python script below.

The problem is that I get ERROR 6: EPSG PCS/GCS code 102184 not found in EPSG support files when QgsGeometryAnalyzer().buffer executes. The EPSG should actually be 3400 for the input points. How can I get this to work?

NOTE: I can enter the commands in the QGIS python console and it works, but the standalone script does not.

setup.bat

SET OSGEO4W_ROOT=C:\OSGeo4W
SET QGISNAME=qgis
SET QGIS=%OSGEO4W_ROOT%\apps\%QGISNAME%
SET QGIS_PREFIX_PATH=%QGIS%

SET PATH=%OSGEO4W_ROOT%\bin;%QGIS%\bin;%PATH%
SET PYTHONHOME=%OSGEO4W_ROOT%\apps\Python27
SET PYTHONPATH=%QGIS%\python;%PYTHONPATH%
SET GDAL_DRIVER_PATH=%OSGEO4W_ROOT%\bin\gdalplugins
SET GDAL_DATA=%OSGEO4W_ROOT%\share\gdal

buffer.py

import os, sys
from qgis.core import *
from qgis.analysis import QgsGeometryAnalyzer

outputPath = r"D:\buffer"
gdb = os.path.join(outputPath, "data.gdb")

size = 500

QgsApplication.setPrefixPath("C:\\OSGeo4W\\apps\\qgis",True)
QgsApplication.initQgis()
tpts = gdb + "|layername=tpts"
tbuff = outputPath + "\\buff.shp"
tptsQgsLyr = QgsVectorLayer(tpts, "tptsQgsLyr", "ogr")
QgsGeometryAnalyzer().buffer(tptsQgsLyr, tbuff, size,  False, True, -1)
QgsApplication.exitQgis()

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.