[Qgis-user] qgis api

Giuseppe Amatulli giuseppe.amatulli at gmail.com
Mon Aug 19 14:45:46 PDT 2013


Solved
In reality the error was in the beginning of the code and it was due to not
set the QgsApplication.setPrefixPath (in ubuntu 12.04 /usr )


import sys
import os
from qgis import *
from qgis.core import *
QgsApplication.setPrefixPath("/usr", True)
QgsApplication.initQgis()
shpA = QgsVectorLayer('/home/selv/tmp/for_clip.shp' , "layerA", "ogr")
shpA.isValid()
True

thanks







On 19 August 2013 15:08, Giuseppe Amatulli <giuseppe.amatulli at gmail.com>wrote:

> Hi,
> i'm trying to create a script that use qgis api to do an intersection
> between two shp .
> The script works fine in the Qgis python console returning "true" and
> creating the intersect
> shp, instead in the python console returns "false"
>
> from qgis.core import *
> from qgis import *
> import qgis.utils
> from qgis import analysis
> from qgis.analysis import *
>
> QgsApplication.initQgis()
>
> shpA = QgsVectorLayer("/home/selv/tmp/for_clip.shp" , "layerA", "ogr")
> shpB = QgsVectorLayer("/home/selv/tmp/bug5598.shp"   , "layerB", "ogr")
> QgsOverlayAnalyzer().intersection( shpA , shpB  ,
> "/home/selv/tmp/test.shp")
>
> so after this lines i get
> true in the qgis python console (the intersect shp is created)
> false in the python console        (the intersect shp is not created)
>
> Should i load other modules? or do i missing something else?
>
> Thanks
> Regards
> Giuseppe
>
>
> --
> Giuseppe Amatulli
> Web: www.spatial-ecology.net
>



-- 
Giuseppe Amatulli
Web: www.spatial-ecology.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20130819/adac652d/attachment.html>


More information about the Qgis-user mailing list