[QGIS-Developer] pyqgis zoom using list widget

2018-01-21 Thread xristosss20
hello i have create a layer filter Expression to get specific results query
from my layer and i add this results in list widget using pyqt.

my Expression and my add to list widget work fine(i take correct ids numbers
in the print and i see that ids in list widget).

but if i want to zoom feature using double click signal in list widget then
i take zoom
in the wrong features(features where my Expression is False).Any idea where
i have wrong in my code and to take wrong features zoom?


my code :

__init__
self.connect(self.ui.listWidget, SIGNAL("itemDoubleClicked (QListWidgetItem
*)"), self.Zoomt)


my filter :
 def myfilter(self):
layer = 
QgsMapLayerRegistry.instance().mapLayersByName("mylayrt")[0]
request = QgsFeatureRequest().setFilterExpression('"name" =
\'{0}\''.format(myname))
 for feature in layer.getFeatures(request):
print str(feature.attribute("myid"))

self.ui.listWidget.addItem(str(feature.attribute("myid")))


result print :

1
42
43
44
45
96
111
304
458
508
579
602
606
646


that is ids add correct in list widget (14 ids).


zoom button .

def Zoomt(self):
Vl_Gs = 
QgsMapLayerRegistry.instance().mapLayersByName("mylayer")[0]
Vl_Gs.removeSelection
Vl_Gs.setSelectedFeatures([self.ui.listWidget.currentRow()])
self.mapCanvas.zoomToSelected(Vl_Gs)

zoom ids (take first 14 from my layer)  :

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14

is len number is correct but the ids zoom is wrong,why?



--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] pyqgis ImportError: DLL load failed: ─ίΊ ▐ΪάΊ ϊΫΊάΪⁿ Ίά ίΊΪΎΏώ≤Ϊί▀ ύ ΆάϋΎ±ώ≤Ή▌Ίύ ΈίώΪ

2017-11-09 Thread xristosss20
I try I create a pyqgis standalone script in windows 10 but I have some
errors

first I have read this post

  
and I follow comment of Mr.caiohamamura but I have semi success I think,and
I don't why happen this this error .

first :

Your PYTHONHOME should be:

C:\OSGeo4W64\apps\Python27
Your PATH should include (in the beggining): 
C:\OSGeo4W64\bin; C:\OSGeo4W64\apps\qgis-ltr-dev\bin 
PYTHONPATH should have:

C:\OSGeo4W64\apps\qgis-ltr-dev\python
C:\OSGeo4W64\apps\qgis-ltr-dev\python\plugins
C:\OSGeo4W64\bin\python27.zip
C:\OSGeo4W64\apps\Python27\DLLs
C:\OSGeo4W64\apps\Python27
C:\OSGeo4W64\apps\Python27\lib
C:\OSGeo4W64\apps\Python27\lib\site-packages
and finally the test.

python in cmd prompt:

 

import qgis
from qgis.core import *

all import without error.

python in Osgeo shell :

 

but if i try to import :

import qgis
from qgis.core import *

then i take ImportError: DLL load failed: ─ίΊ ▐ΪάΊ ϊΫΊάΪⁿ Ίά ίΊΪΎΏώ≤Ϊί▀ ύ
ΆάϋΎ±ώ≤Ή▌Ίύ ΈίώΪ.

why in Osgeo shell I take this error :

ImportError: DLL load failed: ─ίΊ ▐ΪάΊ ϊΫΊάΪⁿ Ίά ίΊΪΎΏώ≤Ϊί▀ ύ ΆάϋΎ±ώ≤Ή▌Ίύ
ΈίώΪ.
what I have wrong ?what is the difference?



--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] pyqgis ImportError: DLL load failed: ─ίΊ ▐ΪάΊ ϊΫΊάΪⁿ Ίά ίΊΪΎΏώ≤Ϊί▀ ύ ΆάϋΎ±ώ≤Ή▌Ίύ ΈίώΪ

2017-11-09 Thread xristosss20
I try I create a pyqgis standalone script in windows 10 but I have some
errors

first I have read this post

  
and I follow comment of Mr.caiohamamura but I have semi success I think,and
I don't why happen this this error .

first :

Your PYTHONHOME should be:

C:\OSGeo4W64\apps\Python27
Your PATH should include (in the beggining): 
C:\OSGeo4W64\bin; C:\OSGeo4W64\apps\qgis-ltr-dev\bin 
PYTHONPATH should have:

C:\OSGeo4W64\apps\qgis-ltr-dev\python
C:\OSGeo4W64\apps\qgis-ltr-dev\python\plugins
C:\OSGeo4W64\bin\python27.zip
C:\OSGeo4W64\apps\Python27\DLLs
C:\OSGeo4W64\apps\Python27
C:\OSGeo4W64\apps\Python27\lib
C:\OSGeo4W64\apps\Python27\lib\site-packages
and finally the test.

python in cmd prompt:

 

import qgis
from qgis.core import *

all import without error.

python in Osgeo shell :

 

but if i try to import :

import qgis
from qgis.core import *

then i take ImportError: DLL load failed: ─ίΊ ▐ΪάΊ ϊΫΊάΪⁿ Ίά ίΊΪΎΏώ≤Ϊί▀ ύ
ΆάϋΎ±ώ≤Ή▌Ίύ ΈίώΪ.

why in Osgeo shell I take this error :

ImportError: DLL load failed: ─ίΊ ▐ΪάΊ ϊΫΊάΪⁿ Ίά ίΊΪΎΏώ≤Ϊί▀ ύ ΆάϋΎ±ώ≤Ή▌Ίύ
ΈίώΪ.
what I have wrong ?what is the difference?



--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] why stop work python.exe in pyqgis standalone script anytime?

2017-07-08 Thread xristosss20
i want to create a simple standalone pyqgis script but i have some
Unexpectedly errors.

here my .bat file :

@echo off
SET OSGEO4W_ROOT=C:\OSGeo4W
call "%OSGEO4W_ROOT%"\bin\o4w_env.bat
call "%OSGEO4W_ROOT%"\apps\grass\grass-7.2.1\etc\env.bat
@echo off
path
%PATH%;%OSGEO4W_ROOT%\apps\qgis\bin;%OSGEO4W_ROOT%\apps\grass\grass-7.2.1\lib
set QGIS_PREFIX_PATH=%OSGEO4W_ROOT:\=/%/apps/qgis
SET PYCHARM="C:\Program Files\JetBrains\PyCharm 2017.1.4\bin\pycharm.exe"

set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis\python;
set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\Python27\Lib\site-packages;

set QGISPATH=%OSGEO4W_ROOT%\apps\qgis

start "PyCharm aware of QGIS" /B %PYCHARM% %*
first i try to see if processing tool work nice.

here the code :

def test1():
qgs = QgsApplication([],True)
QgsApplication.setPrefixPath("C:/OSGeo4W/apps/qgis", True)
qgs.initQgis()
sys.path.append('C:/OSGeo4W/apps/qgis/python/plugins')
import processing
from processing.core.Processing import Processing
Processing.initialize()
print processing.alglist()
qgs.exitQgis()
test1()
work fine i take the list correct

after i try to see if work algorithm where i want

here the code :

def slope():
qgs = QgsApplication([],True)
QgsApplication.setPrefixPath("C:/OSGeo4W/apps/qgis", True)
qgs.initQgis()
sys.path.append('C:/OSGeo4W/apps/qgis/python/plugins')
import processing
from processing.core.Processing import Processing
Processing.initialize()
print processing.alghelp('gdalogr:slope')
qgs.exitQgis()

slope()
and i take this message :

C:\OSGeo4W\bin\python.exe C:/Users/username/PycharmProjects/untitled/test.py
ALGORITHM: Slope
INPUT 
BAND 
COMPUTE_EDGES 
ZEVENBERGEN 
AS_PERCENT 
SCALE 
OUTPUT 


None

Process finished with exit code 0
but anytime to try to run some script with complete code like this :

from qgis.core import QgsApplication
import sys
from qgis.core import QgsRasterLayer
from PyQt4.QtCore import QFileInfo


def slope(raster_path,slope_path):
qgs = QgsApplication([],True)
QgsApplication.setPrefixPath("C:/OSGeo4W/apps/qgis", True)
qgs.initQgis()
sys.path.append('C:/OSGeo4W/apps/qgis/python/plugins')
import processing
from processing.core.Processing import Processing
Processing.initialize()
fileInfo=QFileInfo(raster_path)
baseName=fileInfo.baseName()
rLayer = QgsRasterLayer(fileInfo.filePath(), baseName)
   
processing.runalg('gdalogr:slope',rLayer,1.0,True,True,False,1.0,slope_path)
qgs.exitQgis()

raster_path="C:/Users/username/Desktop/dem.tif"
slope_path="C:/Users/username/Desktop/slope.tif"
slope(raster_path,slope_path)
then before finish script the python.exe stop running :

 

and i take this message in pycharm :

C:\OSGeo4W\bin\python.exe
C:/Users/username/PycharmProjects/untitled/test1.py

Process finished with exit code -1073741819 (0xC005)
that message i take for all scripts with different python code and specific
different algorithms if i want to run it standalone using pycharm editor.

any idea why python.exe stop work anytime ?



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/why-stop-work-python-exe-in-pyqgis-standalone-script-anytime-tp5327125.html
Sent from the QGIS - Developer mailing list archive at Nabble.com.
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] pyqgis error messages using PYCHARM

2017-07-01 Thread xristosss20
I use pyqgis in standalone app using python 2.7 in windows 10.

I have create some scripts using python idle and work fine without some
errors or messages.

Now I try to use pyqgis using pycharm editor with the some scripts where I
have run it before in python editor.

in the pycharm that scripts work again,I get correct outputs but in the
pycharm show me some errors messages and in the final show crashed error
python but my output is correct.

like this :

QSqlDatabase: QSQLITE driver not loaded
ERROR: Opening of authentication db FAILED
QSqlDatabase: available drivers: QPSQL7 QPSQL QODBC3 QODBC
WARNING: Auth db query exec() FAILED
QSqlQuery::prepare: database not open
ERROR: Opening of authentication db FAILED

Process finished with exit code -1073741819 (0xC005) (and 255)
I don't get exit code 0 I get it -1073741819 (0xC005) and 255.

any idea why I take that error messages in pycharm ?



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/pyqgis-error-messages-using-PYCHARM-tp5326359.html
Sent from the QGIS - Developer mailing list archive at Nabble.com.
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] Enable composer atlas labels and styles using pyqgis

2017-06-12 Thread xristosss20
 try to follow this code to create automate atlas print composer using pyqgis
:

def quick_export(self, ref, stype, scale):

# Add all layers in map canvas to render
myMapRenderer = self.iface.mapCanvas().mapRenderer()

# Load template from file
myComposition = QgsComposition(myMapRenderer)
myFile = os.path.join(os.path.dirname(__file__), 'MMR_Template.qpt')
myTemplateFile = file(myFile, 'rt')
myTemplateContent = myTemplateFile.read()
myTemplateFile.close()
myDocument = QDomDocument()
myDocument.setContent(myTemplateContent)
myComposition.loadFromTemplate(myDocument)

# Get map composition and define scale
myAtlasMap = myComposition.getComposerMapById(0)
myAtlasMap.setNewScale(int(scale))

# Setup Atlas
myAtlas = QgsAtlasComposition(myComposition)
myAtlas.setCoverageLayer(atlas_desktop) # Atlas run from desktop_search
myAtlas.setComposerMap(myAtlasMap)
myAtlas.setFixedScale(True)
myAtlas.fixedScale()
myAtlas.setHideCoverage(False)
myAtlas.setFilterFeatures(True)
myAtlas.setFeatureFilter("reference = '%s'" % (str(ref)))
myAtlas.setFilterFeatures(True)

# Generate atlas
myAtlas.beginRender()
for i in range(0, myAtlas.numFeatures()):
myAtlas.prepareForFeature( i )
jobs = r"\\MSUKSERVER\BusinessMan Docs\Jobs"
job_fol = os.path.join(jobs, str(ref))
output_jpeg = os.path.join(job_fol, ref + "_BMS_plan.jpg")
myImage = myComposition.printPageAsRaster(0)
myImage.save(output_jpeg)
myAtlas.endRender()

specific in atlas with same changes code say :

myAtlasMap = myComposition.getComposerMapById(0)
myAtlas = QgsAtlasComposition(myComposition)
myAtlas.setCoverageLayer(atlas_desktop)
myAtlas.setComposerMap(myAtlasMap)
myAtlas.setFixedScale(True)
myAtlas.fixedScale()
myAtlas.setHideCoverage(False)
myAtlas.setFilterFeatures(True)

this code work for my task and i take  export new 100 atlas feutures maps

but in my template.qpt i have some labels with code like this :

QGIS [%concat( "OBJECTID" )%]

that OBJECTID is the same for all new 100 atlas feutures maps. Any idea why?
If I use manual atlas export, then for any map OBJECTID change.

And the true is Does not work anything related to layer atlas in my
template.qpt i have some base styles rules or base labels rules like this :

intersects($atlasgeometry, $geometry ) 

or

$id = $atlasfeatureid

but that styles not work with this code.

i think so that code just export one by one my feutures from my atlas layer
and the atlas in me template stay False.

any idea ?i want to lern this solution is interesting question



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Enable-composer-atlas-labels-and-styles-using-pyqgis-tp5323880.html
Sent from the QGIS - Developer mailing list archive at Nabble.com.
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer