[Qgis-developer] QGIS 2.18.4, splitting a curve results in line geometries

2017-03-03 Thread Eric Goddard
Hi everyone,

I have some MultiCurve geometries in PostGIS. When I split a curve in
QGIS, both of the new geometries are converted to linestrings. I
couldn't find anything from googling, so I'm not sure if this is a
known issue.

Thanks,
Eric
___
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

Re: [Qgis-developer] Using Processing in standalone PYQGIS scripts

2016-09-30 Thread Eric Goddard
Thank you Victor and Etienne, the capital Initialize() got me :( It's
always the little things - sorry about that! Now the processing script
runs successfully as a standalone script but still has the issue of
not selecting anything in the input layer. I was able to use the
QgsVectorLayer variables as inputs to the tool, but it still didn't
select the features.

Thanks,
Eric

On Fri, Sep 30, 2016 at 9:24 AM, Victor Olaya  wrote:
> Not sure why it is not selecting your features. I will try to
> reproduce it and will let you know
>
> About the layers and how they are found, here is some info: Input
> layers for Processing are data sources (if a layer is file based, that
> means the filepath to it). If you enter something that is not that,
> Processing tries to figure out what you mean, basically checking if
> any of your layers has the name you entered, and then using it's
> layer.source() value. But for that, the layer must be loaded. To avoid
> that, you can directly enter the path to your layer, instead of a
> layer name
>
> I will let you know once i can reproduce your issue and find out what
> is happening
>
> Cheers
>
> 2016-09-30 16:07 GMT+02:00 Etienne Trimaille :
>>> AttributeError: class Processing has no attribute 'Initialize'
>>
>> Did you try : 'initialize' ?
>> According to
>> https://github.com/qgis/QGIS/blob/master/python/plugins/processing/core/Processing.py#L146
>>
>> 2016-09-30 20:51 GMT+07:00 Eric Goddard :
>>>
>>> Thanks Victor, I had tried that within the QGIS Python console and got
>>> the same error about the number of arguments. When I drop the OUTPUT
>>> parameter it runs, so now my call looks like this:
>>>
>>> processing.runalg('qgis:selectbylocation', "photos", "boundaries",
>>> u'intersect', 0.0, 0)
>>>
>>> If I run just this line in the interpreter, it outputs:  {'OUTPUT':
>>> u'/home/eric/Development/csi_data_collection/scripts/photos.gpkg'}
>>>
>>> However, it doesn't select any of the points within the selected
>>> polygon boundary. If I run the tool from the Processing Toolbox, it
>>> does select the points within the boundary. When running that tool
>>> from python should it use selected features in the intersection layer?
>>> I tried it with no boundaries selected and it still didn't select
>>> anything.
>>>
>>> Thanks again for the response. Making progress, but it would still be
>>> good to get clarification on how/if Processing can be used from
>>> standalone scripts. in the call to to runalg I did have to change the
>>> layer inputs from the variables containing references to the
>>> QgsVectorLayer objects to the layer name that I passed to those vector
>>> layers on creation. Processing also couldn't find the layers until I
>>> added them to the QgsMapLayerRegistry instance, which I think means
>>> when I instantiate the QgsApplication in the standalone script I need
>>> to pass True instead of False for it to use the GUI?
>>>
>>>
>>>
>>> On Thu, Sep 29, 2016 at 4:25 PM, Victor Olaya  wrote:
>>> > looks like the docs are outdated and the way to call the algorithm is
>>> > now different
>>> >
>>> > ALGORITHM: Select by location
>>> > INPUT 
>>> > INTERSECT 
>>> > PREDICATE 
>>> > PRECISION 
>>> > METHOD 
>>> > OUTPUT 
>>> >
>>> > The PRECISION parameter is not documented in the help file.
>>> >
>>> > Hope this helps
>>> >
>>> > 2016-09-29 22:39 GMT+02:00 Eric Goddard :
>>> >> Hello everyone,
>>> >>
>>> >> I'm using QGIS 2.16.3 on Ubuntu 14.04 (from the qgis.org/ubuntugis
>>> >> repo with ubuntugis-unstable ppa). I have a geopackage layer (I
>>> >> originally started out with a spatialitelayer, but I kept getting
>>> >>
>>> >> ASSERT: "i.value() == handle" in file
>>> >>
>>> >> /tmp/buildd/qgis-2.16.3+20trusty/src/providers/spatialite/qgsspatialiteconnection.cpp,
>>> >> line 780
>>> >> Aborted (core dumped)
>>> >>
>>> >> when calling getFeatures() on the layer) with two columns that I want
>>> >> to populate. One contains the month and year a photo was taken,
>>> >> extracted from EXIF metadata. The other is for the name of the p

Re: [Qgis-developer] Using Processing in standalone PYQGIS scripts

2016-09-30 Thread Eric Goddard
Thanks Victor, I had tried that within the QGIS Python console and got
the same error about the number of arguments. When I drop the OUTPUT
parameter it runs, so now my call looks like this:

processing.runalg('qgis:selectbylocation', "photos", "boundaries",
u'intersect', 0.0, 0)

If I run just this line in the interpreter, it outputs:  {'OUTPUT':
u'/home/eric/Development/csi_data_collection/scripts/photos.gpkg'}

However, it doesn't select any of the points within the selected
polygon boundary. If I run the tool from the Processing Toolbox, it
does select the points within the boundary. When running that tool
from python should it use selected features in the intersection layer?
I tried it with no boundaries selected and it still didn't select
anything.

Thanks again for the response. Making progress, but it would still be
good to get clarification on how/if Processing can be used from
standalone scripts. in the call to to runalg I did have to change the
layer inputs from the variables containing references to the
QgsVectorLayer objects to the layer name that I passed to those vector
layers on creation. Processing also couldn't find the layers until I
added them to the QgsMapLayerRegistry instance, which I think means
when I instantiate the QgsApplication in the standalone script I need
to pass True instead of False for it to use the GUI?



On Thu, Sep 29, 2016 at 4:25 PM, Victor Olaya  wrote:
> looks like the docs are outdated and the way to call the algorithm is
> now different
>
> ALGORITHM: Select by location
> INPUT 
> INTERSECT 
> PREDICATE 
> PRECISION 
> METHOD 
> OUTPUT 
>
> The PRECISION parameter is not documented in the help file.
>
> Hope this helps
>
> 2016-09-29 22:39 GMT+02:00 Eric Goddard :
>> Hello everyone,
>>
>> I'm using QGIS 2.16.3 on Ubuntu 14.04 (from the qgis.org/ubuntugis
>> repo with ubuntugis-unstable ppa). I have a geopackage layer (I
>> originally started out with a spatialitelayer, but I kept getting
>>
>> ASSERT: "i.value() == handle" in file
>> /tmp/buildd/qgis-2.16.3+20trusty/src/providers/spatialite/qgsspatialiteconnection.cpp,
>> line 780
>> Aborted (core dumped)
>>
>> when calling getFeatures() on the layer) with two columns that I want
>> to populate. One contains the month and year a photo was taken,
>> extracted from EXIF metadata. The other is for the name of the polygon
>> that contains the point feature. Extracting the date from the metadata
>> works fine, but I'm having some serious difficulties with running the
>> 'qgis:selectbylocation' processing algorithm in a standalone script.
>> Stack Overflow has several posts on using Processing in standalone
>> scripts, the most recent of which [1] I tried. It crashes on line 15
>> in my script [2](Processing.initialize()) with the following error
>> message:
>>
>> The current error message I'm getting is:
>> Error in sys.excepthook:
>> Traceback (most recent call last):
>>   File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 196, in
>> qgis_excepthook
>> showException(type, value, tb, None, messagebar=True)
>>   File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 107, in
>> showException
>> open_stack_dialog(type, value, tb, msg)
>>   File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 142, in
>> open_stack_dialog
>> iface.messageBar().popWidget()
>> AttributeError: 'NoneType' object has no attribute 'messageBar'
>>
>> Original exception was:
>> Traceback (most recent call last):
>>   File "extract_image_dates.py", line 14, in 
>> Processing.Initialize()
>> AttributeError: class Processing has no attribute 'Initialize'
>>
>>
>> Since I was unable to get it running in the standalone script, I
>> loaded the script I wrote in the QGIS Python console. It ran, but it
>> said that the number of arguments to 'qgis:selectbylocation' was
>> wrong, but my call to the algorithim on line 55 matches the docs [3].
>>
>> Any pointers on how to get this working would be greatly appreciated,
>> and I'd be happy to make a PR on the QGIS Documentation to add a
>> section about it once it works.
>>
>>
>> Thanks!
>> Eric
>>
>> [1] 
>> http://gis.stackexchange.com/questions/129915/cannot-run-standalone-qgis-script
>> [2] https://gist.github.com/egoddard/c188c62115f2fe8df24f32b3119e51b3
>> [3] 
>> http://docs.qgis.org/2.14/en/docs/user_manual/processing_algs/qgis/vector_selection_tools.html#select-by-location
>> ___
>> Qgis-developer mailing list
>> Qgis-developer@lists.osgeo.org
>> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

[Qgis-developer] Using Processing in standalone PYQGIS scripts

2016-09-29 Thread Eric Goddard
Hello everyone,

I'm using QGIS 2.16.3 on Ubuntu 14.04 (from the qgis.org/ubuntugis
repo with ubuntugis-unstable ppa). I have a geopackage layer (I
originally started out with a spatialitelayer, but I kept getting

ASSERT: "i.value() == handle" in file
/tmp/buildd/qgis-2.16.3+20trusty/src/providers/spatialite/qgsspatialiteconnection.cpp,
line 780
Aborted (core dumped)

when calling getFeatures() on the layer) with two columns that I want
to populate. One contains the month and year a photo was taken,
extracted from EXIF metadata. The other is for the name of the polygon
that contains the point feature. Extracting the date from the metadata
works fine, but I'm having some serious difficulties with running the
'qgis:selectbylocation' processing algorithm in a standalone script.
Stack Overflow has several posts on using Processing in standalone
scripts, the most recent of which [1] I tried. It crashes on line 15
in my script [2](Processing.initialize()) with the following error
message:

The current error message I'm getting is:
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 196, in
qgis_excepthook
showException(type, value, tb, None, messagebar=True)
  File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 107, in
showException
open_stack_dialog(type, value, tb, msg)
  File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 142, in
open_stack_dialog
iface.messageBar().popWidget()
AttributeError: 'NoneType' object has no attribute 'messageBar'

Original exception was:
Traceback (most recent call last):
  File "extract_image_dates.py", line 14, in 
Processing.Initialize()
AttributeError: class Processing has no attribute 'Initialize'


Since I was unable to get it running in the standalone script, I
loaded the script I wrote in the QGIS Python console. It ran, but it
said that the number of arguments to 'qgis:selectbylocation' was
wrong, but my call to the algorithim on line 55 matches the docs [3].

Any pointers on how to get this working would be greatly appreciated,
and I'd be happy to make a PR on the QGIS Documentation to add a
section about it once it works.


Thanks!
Eric

[1] 
http://gis.stackexchange.com/questions/129915/cannot-run-standalone-qgis-script
[2] https://gist.github.com/egoddard/c188c62115f2fe8df24f32b3119e51b3
[3] 
http://docs.qgis.org/2.14/en/docs/user_manual/processing_algs/qgis/vector_selection_tools.html#select-by-location
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] how to active tool located in standard QGIS toolbar from a plugin

2016-06-09 Thread Eric Goddard
Is this in a pyqgis plugin? You should be able to activate the select tool
with iface.actionSelect().trigger(). You can also use
actionSelectFreehand(), actionSelectPolygon(), actionSelectRadius(), or
actionSelectRectange().

Eric

On Thu, Jun 9, 2016 at 8:27 AM Martin Landa  wrote:

> Hi all,
>
> I would like to duplicate some of standard QGIS tools in my plugin. In
> other words I have in my plugin an icon for selecting features. Is
> there any way how to automatically activate, after choosing this tool
> from my plugin, standard QGIS tool called 'Select Features by area or
> single click' without code duplication?
>
> Thanks a lot for any kind of hint in advance, Martin
>
> --
> Martin Landa
> http://geo.fsv.cvut.cz/gwiki/Landa
> http://gismentors.cz/mentors/landa
> ___
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] QGIS/Linux on high-resolution displays

2016-06-08 Thread Eric Goddard
Hi Barry,

I also have the developer edition of the XPS 13. I've replaced ubuntu
14.04 with Fedora 23, but I think changing the following settings
should work for you too. Change the Style, Icon size, and Font sizes
in QGIS under Settings -> Options.

Changing the Style from GTK+ to Adwaita fixed some of the issues with
drop-downs, buttons, and cell sizes in the attribute table cutting off
the text. You may not have that problem though; I can't remember if
that issue came before or after the switch to Fedora/Gnome 3.

Changing the font size to 11 and the icon size to 48 works for me and
feels pretty 'standard'. Since making those changes QGIS is working
wonderfully on the XPS 13.

Hope that helps!
Eric

On Wed, Jun 8, 2016 at 1:34 PM, Barry Rowlingson
 wrote:
> On Wed, Jun 8, 2016 at 6:24 AM, Alessandro Pasotti  wrote:
>> 2016-06-07 23:17 GMT+02:00 Barry Rowlingson :
>>>
>>> Ive just bought a Dell XPS13 which came with Ubuntu 14.04
>>> pre-installed. The screen is 3200 pixels across. Getting applications
>>> to scale properly is a nightmare.
>>>
>>> QGIS (and I guess all Qt apps) seems to be the worst. The icons are
>>> microscopic, and the text and other interface elements overlap. It is
>>> unusable. Same for Gimp and Inkscape, but I mostly use QGIS.
>>
>>
>>
>> QGIS works pretty well (with some minor glitches) in KDE on 4K and retina
>> screens, see the tips and the links in this article
>> http://www.itopen.it/qgis-and-qt-getting-ready-for-hidpi-screens/
>
> Hmm I had more than minor glitches. The problem is that there were so
> many possible things to tweak I could never be sure what was helping!
>
>> No, try setting:
>> - the dpi resolution in the display configuration of your OS (system
>> settings), that is usually a wrapper for xrandr
>> - for QT5, the env vars  QT_DEVICE_PIXEL_RATIO=2 and/or
>> QT_SCREEN_SCALE_FACTORS=2
>> - icon size in QGIS can be (at least in part, for the toolbar) configured in
>> the QGIS options dialog
>>
>> See also: http://doc.qt.io/qt-5/highdpi.html
>>
>
> Since those are all Qt5 things they're no good with QGIS at the
> moment, yes? Or is there a QGIS built against Qt5.6+ that I could be
> using?
>
>  I've got the icons scaled up now, but there's still some tiny UI
> elements - the visibility toggles on layers, and the little plus signs
> that expand trees are almost invisible...
>
> thanks for the tips
>
> Barry
> ___
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] PyQGIS Segmentation fault when reading from Spatialite data source

2016-05-01 Thread Eric Goddard
Deleting the layer works around the crash. I feel somewhat silly for
not trying such a simple solution :). Instead I tried removing the
layer from the map registry before closing, but it still segfaulted.
Thanks for the help!

Though it works without crashing now, the behavior for spatialite is
still different from other data sources. If I connect to a postgis
layer, check that it is valid and then call exitQgis(), it doesn't
crash.

On Sun, May 1, 2016 at 9:22 AM, Martin Dobias  wrote:
> Hi Eric
>
> On Sat, Apr 30, 2016 at 12:06 AM, Eric Goddard  wrote:
>> Hello all,
>>
>> I'm working on a sync script for use with IntraMaps Roam for offline
>> editing. My QGIS version is 2.14.1 (Tested on Fedora 23, Ubuntu 14.04,
>> and Windows 7 x64). I'm using a standalone pyqgis script that creates
>> the connection to the postgis data source and the spatialite
>> datasource that roam uses locally. At this step I've just checked that
>> each layer is valid, which they are, but after calling the exitQgis()
>> method at the end of the script I get a segmentation fault. I think it
>> is related to https://github.com/qgis/QGIS/pull/2944, but that
>> specifically says for invalid layers.
>>
>> [...]
>>
>> sp_layer = QgsVectorLayer(sp_uri.uri(), "Disconnected Layer", "spatialite")
>>
>> print sp_layer.isValid() # Prints True
>>
>> qgs.exitQgis() # segfault :(
>
> I think you need to delete "sp_layer" before calling exitQgis(). The
> call to exitQgis() will invalidate the whole QGIS environment, so
> later when sp_layer is auto-deleted by Python at the end of the
> script, that will cause segfault. So simply try to add "del sp_layer"
> line before exitQgis()
>
> Cheers
> Martin
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

[Qgis-developer] PyQGIS Segmentation fault when reading from Spatialite data source

2016-04-29 Thread Eric Goddard
Hello all,

I'm working on a sync script for use with IntraMaps Roam for offline
editing. My QGIS version is 2.14.1 (Tested on Fedora 23, Ubuntu 14.04,
and Windows 7 x64). I'm using a standalone pyqgis script that creates
the connection to the postgis data source and the spatialite
datasource that roam uses locally. At this step I've just checked that
each layer is valid, which they are, but after calling the exitQgis()
method at the end of the script I get a segmentation fault. I think it
is related to https://github.com/qgis/QGIS/pull/2944, but that
specifically says for invalid layers.

I tried removing the layer from the QgsMapLayerRegistry, but that
doesn't help. Is there another way I can try to explicitly close the
connection to avoid the segmentation fault? Technically everything
will complete before the crash, but I don't know how IntraMaps roam
will respond to the sync script crashing, and I would (obviously)
prefer my script to not crash every time it runs. The code is below.

import os
import sys
from qgis.core import *

QgsApplication.setPrefixPath("C:/OsGeo4W/apps/qgis", True)
qgs = QgsApplication(sys.argv, False)
qgis.initQgis()

sp_uri = QgsDataSourceURI()
sp_uri.setDatabase('_data/csis.sqlite')
schema = ''
table = 'facilities_envt'
geom_column = 'Geometry'
sp_uri.setDataSource(schema, table, geom_column)
sp_layer = QgsVectorLayer(sp_uri.uri(), "Disconnected Layer", "spatialite")

print sp_layer.isValid() # Prints True

qgs.exitQgis() # segfault :(

Thanks!
Eric
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] processing.runalg() issue with grass algorithms

2014-03-25 Thread Eric Goddard
Thanks, I knew they returned dictionaries, but I forgot to change the
call to runalg to have lpf as the output argument. The script executes
with the SAGA algorithm.



On Tue, Mar 25, 2014 at 5:25 PM, Victor Olaya  wrote:
> The runalg method does not return a layer. It returns a dict with the
> outputs of the algorithms. Keys are output names, values are paths to
> output objects
>
> Hope this helps
>
> 2014-03-25 22:36 GMT+01:00 Eric Goddard :
>> Alright, latest master (9e42c5b), with processing version
>> 2.0-20131120. Running a custom tool that consists of the following
>> code results in an error:
>>
>> ##dem=raster
>> ##radius=number 4
>> ##lpf=output raster
>>
>> lpf = processing.runalg("saga:simplefilter", dem, 0, 0, radius, None)
>>
>>
>> An error has occured while executing Python code:
>>
>> Traceback (most recent call last):
>>   File 
>> "/home/eric/.qgis2/python/plugins/processing/gui/AlgorithmExecutionDialog.py",
>> line 256, in accept
>> self.finish()
>>   File 
>> "/home/eric/.qgis2/python/plugins/processing/gui/AlgorithmExecutionDialog.py",
>> line 281, in finish
>> Postprocessing.handleAlgorithmResults(self.alg, self, not keepOpen)
>>   File "/home/eric/.qgis2/python/plugins/processing/gui/Postprocessing.py",
>> line 77, in handleAlgorithmResults
>> dlg = CouldNotLoadResultsDialog(wrongLayers, alg)
>>   File 
>> "/home/eric/.qgis2/python/plugins/processing/gui/CouldNotLoadResultsDialog.py",
>> line 41, in __init__
>> self.setupUi()
>>   File 
>> "/home/eric/.qgis2/python/plugins/processing/gui/CouldNotLoadResultsDialog.py",
>> line 50, in setupUi
>> html = self.alg.getPostProcessingErrorMessage(self.wrongLayers)
>>   File "/home/eric/.qgis2/python/plugins/processing/core/GeoAlgorithm.py",
>> line 520, in getPostProcessingErrorMessage
>> + layer.value + '\n'
>> TypeError: cannot concatenate 'str' and 'dict' objects
>>
>>
>> Python version:
>> 2.7.6 (default, Feb 26 2014, 12:07:17)
>> [GCC 4.8.2 20140206 (prerelease)]
>>
>>
>> QGIS version:
>> 2.3.0-Master Master, 9e42c5b
>>
>> Python path: ['/home/eric/.qgis2/python/plugins/processing',
>> '/usr/share/qgis/python', u'/home/eric/.qgis2/python',
>> u'/home/eric/.qgis2/python/plugins', '/usr/share/qgis/python/plugins',
>> '/usr/lib/python27.zip', '/usr/lib/python2.7',
>> '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk',
>> '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload',
>> '/usr/lib/python2.7/site-packages',
>> '/usr/lib/python2.7/site-packages/gtk-2.0',
>> '/usr/lib/python2.7/site-packages/wx-3.0-gtk2',
>> '/usr/share/qgis/python/plugins/fTools/tools', '/home/eric/Documents']
>>
>>
>> Running the code in the console completes successfully. However, I'm
>> still unable to run a grass algorithm when the grass_region_parameter
>> and grass_region_cellsize_parameter are set to None.
>>
>> Thanks,
>> Eric
>>
>> On Mon, Mar 24, 2014 at 10:13 PM, Eric Goddard  
>> wrote:
>>> Oops, my mistake. I have ##lrm=output raster in the header, but lpf = ... Is
>>> the only line in my code.
>>>
>>> I don't get the error message after changing lrm to lpf in the header. I do
>>> get another error message, but I think I broke my processing by trying to
>>> force an update. I'll test it tomorrow. Sorry about the confusion!
>>>
>>> Eric
>>>
>>> On Mar 22, 2014 5:06 PM, "Eric Goddard"  wrote:
>>>>
>>>> Ah, I didn't know a file could he specified without a path. Thanks for the
>>>> clarification!
>>>>
>>>> On Mar 22, 2014 4:37 PM, "Victor Olaya"  wrote:
>>>>>
>>>>> > If I run the same line in the python console, it works correctly:
>>>>> >>>> radius = 4
>>>>> >>>> lpf = processing.runalg("saga:simplefilter", "SR_50M_alaska_nad", 0,
>>>>> >>>> 0, radius, None)
>>>>> >>>> processing.load(lpf['RESULT'])
>>>>> >
>>>>> > Results in the map being loaded.
>>>>>
>>>>> Not sure why this is happening. I will try to reproduce the error and
>>>>> see if it can be fixed
>>>>> Thanks for the report
>>>>>
>>>>> >
>>>>> > Also, if I change the output folder in the processing settings to a
>>>>> > different location (in this case, tmp/processing in my home folder)
>>>>> > and run another algorithm in the python console, the RESULT key still
>>>>> > points to /tmp/processing/...
>>>>>
>>>>> This is not a bug. If you do not enter a filename, the output will
>>>>> always go to a temporary file. The output folder that yu can set in
>>>>> the settings  is the folder to be used when you enter a filename
>>>>> without a path (like "myfile.shp", but not "/home/myuser/myfile.shp"),
>>>>> not the folder to use for temporary files.
>>>>>
>>>>> Thanks again!
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] processing.runalg() issue with grass algorithms

2014-03-25 Thread Eric Goddard
Alright, latest master (9e42c5b), with processing version
2.0-20131120. Running a custom tool that consists of the following
code results in an error:

##dem=raster
##radius=number 4
##lpf=output raster

lpf = processing.runalg("saga:simplefilter", dem, 0, 0, radius, None)


An error has occured while executing Python code:

Traceback (most recent call last):
  File 
"/home/eric/.qgis2/python/plugins/processing/gui/AlgorithmExecutionDialog.py",
line 256, in accept
self.finish()
  File 
"/home/eric/.qgis2/python/plugins/processing/gui/AlgorithmExecutionDialog.py",
line 281, in finish
Postprocessing.handleAlgorithmResults(self.alg, self, not keepOpen)
  File "/home/eric/.qgis2/python/plugins/processing/gui/Postprocessing.py",
line 77, in handleAlgorithmResults
dlg = CouldNotLoadResultsDialog(wrongLayers, alg)
  File 
"/home/eric/.qgis2/python/plugins/processing/gui/CouldNotLoadResultsDialog.py",
line 41, in __init__
self.setupUi()
  File 
"/home/eric/.qgis2/python/plugins/processing/gui/CouldNotLoadResultsDialog.py",
line 50, in setupUi
html = self.alg.getPostProcessingErrorMessage(self.wrongLayers)
  File "/home/eric/.qgis2/python/plugins/processing/core/GeoAlgorithm.py",
line 520, in getPostProcessingErrorMessage
+ layer.value + '\n'
TypeError: cannot concatenate 'str' and 'dict' objects


Python version:
2.7.6 (default, Feb 26 2014, 12:07:17)
[GCC 4.8.2 20140206 (prerelease)]


QGIS version:
2.3.0-Master Master, 9e42c5b

Python path: ['/home/eric/.qgis2/python/plugins/processing',
'/usr/share/qgis/python', u'/home/eric/.qgis2/python',
u'/home/eric/.qgis2/python/plugins', '/usr/share/qgis/python/plugins',
'/usr/lib/python27.zip', '/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload',
'/usr/lib/python2.7/site-packages',
'/usr/lib/python2.7/site-packages/gtk-2.0',
'/usr/lib/python2.7/site-packages/wx-3.0-gtk2',
'/usr/share/qgis/python/plugins/fTools/tools', '/home/eric/Documents']


Running the code in the console completes successfully. However, I'm
still unable to run a grass algorithm when the grass_region_parameter
and grass_region_cellsize_parameter are set to None.

Thanks,
Eric

On Mon, Mar 24, 2014 at 10:13 PM, Eric Goddard  wrote:
> Oops, my mistake. I have ##lrm=output raster in the header, but lpf = ... Is
> the only line in my code.
>
> I don't get the error message after changing lrm to lpf in the header. I do
> get another error message, but I think I broke my processing by trying to
> force an update. I'll test it tomorrow. Sorry about the confusion!
>
> Eric
>
> On Mar 22, 2014 5:06 PM, "Eric Goddard"  wrote:
>>
>> Ah, I didn't know a file could he specified without a path. Thanks for the
>> clarification!
>>
>> On Mar 22, 2014 4:37 PM, "Victor Olaya"  wrote:
>>>
>>> > If I run the same line in the python console, it works correctly:
>>> >>>> radius = 4
>>> >>>> lpf = processing.runalg("saga:simplefilter", "SR_50M_alaska_nad", 0,
>>> >>>> 0, radius, None)
>>> >>>> processing.load(lpf['RESULT'])
>>> >
>>> > Results in the map being loaded.
>>>
>>> Not sure why this is happening. I will try to reproduce the error and
>>> see if it can be fixed
>>> Thanks for the report
>>>
>>> >
>>> > Also, if I change the output folder in the processing settings to a
>>> > different location (in this case, tmp/processing in my home folder)
>>> > and run another algorithm in the python console, the RESULT key still
>>> > points to /tmp/processing/...
>>>
>>> This is not a bug. If you do not enter a filename, the output will
>>> always go to a temporary file. The output folder that yu can set in
>>> the settings  is the folder to be used when you enter a filename
>>> without a path (like "myfile.shp", but not "/home/myuser/myfile.shp"),
>>> not the folder to use for temporary files.
>>>
>>> Thanks again!
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] processing.runalg() issue with grass algorithms

2014-03-24 Thread Eric Goddard
Oops, my mistake. I have ##lrm=output raster in the header, but lpf = ...
Is the only line in my code.

I don't get the error message after changing lrm to lpf in the header. I do
get another error message, but I think I broke my processing by trying to
force an update. I'll test it tomorrow. Sorry about the confusion!

Eric
On Mar 22, 2014 5:06 PM, "Eric Goddard"  wrote:

> Ah, I didn't know a file could he specified without a path. Thanks for the
> clarification!
> On Mar 22, 2014 4:37 PM, "Victor Olaya"  wrote:
>
>> > If I run the same line in the python console, it works correctly:
>> >>>> radius = 4
>> >>>> lpf = processing.runalg("saga:simplefilter", "SR_50M_alaska_nad", 0,
>> 0, radius, None)
>> >>>> processing.load(lpf['RESULT'])
>> >
>> > Results in the map being loaded.
>>
>> Not sure why this is happening. I will try to reproduce the error and
>> see if it can be fixed
>> Thanks for the report
>>
>> >
>> > Also, if I change the output folder in the processing settings to a
>> > different location (in this case, tmp/processing in my home folder)
>> > and run another algorithm in the python console, the RESULT key still
>> > points to /tmp/processing/...
>>
>> This is not a bug. If you do not enter a filename, the output will
>> always go to a temporary file. The output folder that yu can set in
>> the settings  is the folder to be used when you enter a filename
>> without a path (like "myfile.shp", but not "/home/myuser/myfile.shp"),
>> not the folder to use for temporary files.
>>
>> Thanks again!
>>
>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] processing.runalg() issue with grass algorithms

2014-03-22 Thread Eric Goddard
Ah, I didn't know a file could he specified without a path. Thanks for the
clarification!
On Mar 22, 2014 4:37 PM, "Victor Olaya"  wrote:

> > If I run the same line in the python console, it works correctly:
>  radius = 4
>  lpf = processing.runalg("saga:simplefilter", "SR_50M_alaska_nad", 0,
> 0, radius, None)
>  processing.load(lpf['RESULT'])
> >
> > Results in the map being loaded.
>
> Not sure why this is happening. I will try to reproduce the error and
> see if it can be fixed
> Thanks for the report
>
> >
> > Also, if I change the output folder in the processing settings to a
> > different location (in this case, tmp/processing in my home folder)
> > and run another algorithm in the python console, the RESULT key still
> > points to /tmp/processing/...
>
> This is not a bug. If you do not enter a filename, the output will
> always go to a temporary file. The output folder that yu can set in
> the settings  is the folder to be used when you enter a filename
> without a path (like "myfile.shp", but not "/home/myuser/myfile.shp"),
> not the folder to use for temporary files.
>
> Thanks again!
>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] processing.runalg() issue with grass algorithms

2014-03-22 Thread Eric Goddard
Hello again,

Still having issues with processing, QGIS master (942d5da) compiled
today. I have a script I wrote for GRASS that i'm trying to port over
to QGIS. I'm testing the first step to make sure it is going to work
before I write the whole thing; it consists of:

  1 ##dem=raster
  2 ##radius=number 4
  3 ##lrm=output raster
  4
  5 lpf = processing.runalg("saga:simplefilter", dem, 0, 0, radius, None)

If I run this script, I get the following error:

Oooops! The following output layers could not be open
lrm: /tmp/processing/caa3afc6e3c6437893392b173985697c/lrm.tif
The above files could not be opened, which probably indicates that
they were not correctly produced by the executed algorithm
Checking the log information might help you see why those layers were
not created as expected

The Log contains:

Algorithm local relief starting...
Converting outputs
Loading resulting layers
Algorithm local relief finished

If I run the same line in the python console, it works correctly:
>>> radius = 4
>>> lpf = processing.runalg("saga:simplefilter", "SR_50M_alaska_nad", 0, 0, 
>>> radius, None)
>>> processing.load(lpf['RESULT'])

Results in the map being loaded.

Also, if I change the output folder in the processing settings to a
different location (in this case, tmp/processing in my home folder)
and run another algorithm in the python console, the RESULT key still
points to /tmp/processing/...

Any pointers on why the script doesn't run would be appreciated. I
didn't see an existing issue on hub.qgis.org regarding the output
folder issue, so it might be a new bug...

Thanks!
Eric

On Sun, Mar 16, 2014 at 1:21 AM, Eric Goddard  wrote:
> Hi all,
>
> I'm using QGIS 2.3-Master 64-bit, fa157b0 with GRASS 6.4.4svn on linux.
>
> When I pass a grass command to processing.runalg() without specifying
> the GRASS_REGION_PARAMETER or GRASS_REGION_CELLSIZE_PARAMETER, I get
> an empty output because the region/cell size are invalid. For example,
> using the qgis sample data, if I run:
>
> lpf = processing.runalg("grass:r.neighbors", "SR_50M_alaska_nad", 0,
> 9, False, False, None, None, None, None)
>
> there is an output key in lpf that points to a tif, but that tif
> doesnt exist. Looking at the log, the above command is translated to:
>
> processing.runalg("grass:r.neighbors","/data/GIS/qgis_sample_data/raster/SR_50M_alaska_nad.tif",0,9,False,False,"None","0,1,0,1",0.0,None)
>
> If one runs the r.neighbors algorithm from the Processing Toolbox,
> leaving the region and cell size at the defaults (blank and 0.00)
> works correctly. How can a similar behavior be achieved  when running
> the command through processing.runalg()?
>
> And on a somewhat related note, when running a grass algorithm from
> the toolbox there is an option to select extent on canvas--can this be
> used in custom processing scripts?
>
> Thanks!
> Eric
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] processing.runalg() issue with grass algorithms

2014-03-15 Thread Eric Goddard
Hi all,

I'm using QGIS 2.3-Master 64-bit, fa157b0 with GRASS 6.4.4svn on linux.

When I pass a grass command to processing.runalg() without specifying
the GRASS_REGION_PARAMETER or GRASS_REGION_CELLSIZE_PARAMETER, I get
an empty output because the region/cell size are invalid. For example,
using the qgis sample data, if I run:

lpf = processing.runalg("grass:r.neighbors", "SR_50M_alaska_nad", 0,
9, False, False, None, None, None, None)

there is an output key in lpf that points to a tif, but that tif
doesnt exist. Looking at the log, the above command is translated to:

processing.runalg("grass:r.neighbors","/data/GIS/qgis_sample_data/raster/SR_50M_alaska_nad.tif",0,9,False,False,"None","0,1,0,1",0.0,None)

If one runs the r.neighbors algorithm from the Processing Toolbox,
leaving the region and cell size at the defaults (blank and 0.00)
works correctly. How can a similar behavior be achieved  when running
the command through processing.runalg()?

And on a somewhat related note, when running a grass algorithm from
the toolbox there is an option to select extent on canvas--can this be
used in custom processing scripts?

Thanks!
Eric
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] Problem with GDAL_translate. REST Services, QGIS

2014-03-14 Thread Eric Goddard
Hi Randal,

I'm not really sure why gdal isn't creating the xml file. It looks
like it is gdal, since using the iface.AddRasterLayer() method
produces the same error message as using gdal_translate from the
command line.

As a work around while that issue is being sorted out, if you download
the gdal ArcGIS server TMS xml definition from
http://www.gdal.org/frmt_wms_arcgis_mapserver_tms.xml and change the
url before the /tile/${z}/${y}/${x} portion, it will load the tiles
when dragged into QGIS. I tested it with several of the raster layers
from http://server.arcgisonline.com/ArcGIS/rest/services/ and they all
worked.

Eric

On Thu, Mar 13, 2014 at 2:40 PM, Randal Hale
 wrote:
> Oh yeah - it was completely working. I haven't tried it since the upgrade to
> 2.2 on Ubuntu. That's why I ran through all the variations:
> windows/linux/etc to make sure it wasn't one thing vs something else. It
> seems ultimately to be a gdal thing since it failed on linux and windows.
> Linux was a bit more extreme with the segmentation fault.
>
> Anyway - I'm hoping it's me - but I don't think so.
>
>
> Randy
>
> -
> Randal Hale, GISP
> North River Geographic Systems, Inc
> http://www.northrivergeographic.com
> 423.653.3611 rjh...@northrivergeographic.com
> twitter:rjhale
> http://about.me/rjhale
>
> On 03/13/2014 03:03 PM, Alex Mandel wrote:
>>
>> Randy,
>>
>> So it was working at some point? Is it possible the service has changed?
>>
>> Thanks,
>> Alex
>>
>> On 03/13/2014 11:21 AM, Randal Hale wrote:
>>>
>>> No worries at all!
>>>
>>> I just need to figure out why it stopped working.
>>>
>>> Randy
>>>
>>> -
>>> Randal Hale, GISP
>>> North River Geographic Systems, Inc
>>> http://www.northrivergeographic.com
>>> 423.653.3611 rjh...@northrivergeographic.com
>>> twitter:rjhale
>>> http://about.me/rjhale
>>>
>>> On 03/13/2014 01:55 PM, Lauri Kajan wrote:

 Hi Randy,

 I'm really sorry and little embarrassed for my previous post.
 You sure noticed that I don't have much knowledge in arcgis rest
 services and especially in using those with gdal.

 In this case that json isn't a vector data. It is actually a
 description of a raster service and therefore should be accetable for
 gdal. This was totally my mistake.


 -Lauri





 On Thu, Mar 13, 2014 at 7:28 PM, Alex Mandel
 mailto:tech_...@wildintellect.com>> wrote:

  I wouldn't get on his case too hard he's following:
  http://hub.qgis.org/wiki/quantum-gis/Arcgis_rest

  There's probably some clues in:

 http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/The_ArcGIS_REST_API/02r3005400/


  I think other workarounds could be to pull the layers in the
  OpenLayers
  plugin.

  Thanks,
  Alex

  On 03/13/2014 09:50 AM, Lauri Kajan wrote:
  > Hi Randy,
  >
  > You are requesting json format from arcgisonline. That is a
  vector format
  > and you are trying to use it as a raster image.
  > Secondly you are trying to translate that into WMS with
  gdal_translate.
  > Gdal supports WMS-reading only, not creation (
  > http://gdal.org/formats_list.html).
  >
  > I recommend for you some introduction to GIS and raster and
  vector formats.
  > http://www.qgis.org/en/docs/gentle_gis_introduction/index.html
  >
  >
  > Regards,
  >
  > Lauri
  >
  >
  >
  >
  > On Thu, Mar 13, 2014 at 4:51 PM, Randal Hale <
  > rjh...@northrivergeographic.com
  > wrote:
  >
  >> So I figured I would start here and work my way out...or up.
  Sorry for the
  >> cross posting. I'm hitting a little bit of everything on this
  one. Same
  >> action - different results (sorta). This is all of my attempts
  at adding a
  >> REST Service from ArcGISOnline to QGIS (using GDAL in some
 cases).
  >>
  >> On Ubuntu 12.04 LTS gdal 1.10
  >> This command: gdal_translate "http://server.arcgisonline.
  >>

 com/ArcGIS/rest/services/USA_Topo_Maps/MapServer?f=json&pretty=true"
  >> ESRITopographicLayer.xml -of WMS
  >> Gives me a segmentation fault
  >>
  >> On windows 7 OSGEO4w 32 bit installer gdal 1.10.1
  >> This command: gdal_translate "http://server.arcgisonline.
  >>

 com/ArcGIS/rest/services/USA_Topo_Maps/MapServer?f=json&pretty=true"
  >> ESRITopographicLayer.xml -of WMS
  >> Gives me:
  >> ERROR 4: `/vsimem/http_1/file.dat' not recognised as a
  supported file
  >> format.
  >> ERROR 4: `/tmp/file.dat' not recognised as a supported f

Re: [Qgis-developer] Run stable and master versions of QGIS on Ubuntu

2014-03-11 Thread Eric Goddard
You could try downloading the source package for gdal and modifying
the debian/rules file to add the necessary --with-FileGDB and
--with-MRSID=... lines. Installing the modified gdal with the package
manager should allow it to be used with the stable QGIS from the
ubuntuGIS repo and the development version from debian-nightly. I've
never actually done this with ubuntu/debian but I do the equivalent on
Arch Linux. For ubuntu you would do something like:

mkdir ~/build
cd ~/build
sudo apt-get build-dep gdal
apt-get source gdal
cd gdal-1.10.0 # or whatever directory it unpacks...
nano debian/rules
##edit file to include the necessary --with-FileGDB and --with-MrSID
lines and cd back to the main package directory and build the package:
cd ..
dpkg-buildpackage -us -uc -nc

install the packages with something along the lines of
sudo dpkg -i gdal*

Assuming that worked, you would then probably want to put a hold on
gdal so it doesn't get updated and lose your customizations.

disclaimer: I have never tried this with ubuntu, but that appears to
be the general flow from a little bit of googling.

Eric

On Tue, Mar 11, 2014 at 12:45 PM, Bernd Vogelgesang
 wrote:
> Thanx Remi for bringing this up ... I didn't dare to ...
>
> The problem with compiling the dev version imho is, that you will have to
> recompile it permanently if you are trying to be of any help with bug
> tracking, am I right? (Haven't compiled anything yet, cause I don't get rid
> of the knots in my brain)
>
> On the other hand, to use QGIS "professionaly", I need GDAL with FGDB and
> MrSID support, so I will have to compile GDAL myself beforehand.
> But wanting to use it for work, I better not use the master version but the
> stable.
>
> So, as I see it, it would be much better to compile the stable version and
> then get the master version for the candies and the testing from
> debian-nightly.
> But all guidelines propose it the other way round, which I do not really
> understand ...
>
> Said this, when I want to compile the stable version instead of the master,
> but with a "handmade" GDAL, is there any way to take benefit from the
> ubuntugis-unstable repository (things I can install beforehand and then
> disabling the repository again)?
>
> As I said, I have knots in my brain on this and never managed to have a nice
> and easy environment on Ubuntu as I have with Windows (which is sd)
> Can someone help me with the surgery?
>
> Cheers
> Bernd
>
>
>
> Am 11.03.2014 17:59, schrieb Alex Mandel:
>
> The only non-compile way I can think of on an Ubuntu box would be to run
> a virtual machine. Otherwise you have to compile to avoid package
> manager conflicts.
>
> So up to you which is more time/hassle to setup.
>
> Enjoy,
> Alex
>
> On 03/10/2014 01:26 PM, Etienne Tourigny wrote:
>
> AFAIK, you have to build your own version (preferrably master) with a
> different install prefix (e.g. /home/softdev/), and when you want to use
> that version you need to add relevant paths to PATH and LD_LIBRARY_PATH.
>
> I have a shell function that sets this up on demand:
>
> setup_softdev()
> {
> export SOFT_PREFIX=/home/softdev
> export LD_LIBRARY_PATH="/home/softdev/lib"
> export LIBRARY_PATH=/home/softdev/lib
> export LD_RUN_PATH=/home/softdev/lib
> export PATH=/home/softdev/bin:$PATH
> export CPLUS_INCLUDE_PATH=/home/softdev/include
> export C_INCLUDE_PATH=/home/softdev/include
> export CPPFLAGS=-I/home/softdev/include
> export PYTHONPATH=/home/softdev/lib/python2.7/site-packages/
> export GDAL_DATA=/home/softdev/share/gdal
> }
> export -f setup_softdev
>
>
>
> On Mon, Mar 10, 2014 at 5:19 PM, Rémi Bovard  wrote:
>
> Hi list,
>
> I'm wondering if there is there a simple way to run stable and master
> versions of QGIS on Ubuntu? By simple, I mean - if possible - without
> compile QGIS from source.
>
> For now, as described in doc [1], I edit /etc/apt/sources.list to define
> which repository to use : http://qgis.org/debian or
> http://qgis.org/debian-nightly. But doing like this, I cannot run the two
> versions at the same time.
>
> Thank you in advance for your answers.
>
> Rémi
>
> [1] http://qgis.org/en/site/forusers/alldownloads.html#ubuntu
>
>
> ___
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>
> ___
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] Finding duplicate records

2014-03-01 Thread Eric Goddard
Python can also be used to find duplicate attributes. It isn't as
straightforward as a sql query, but it works. And if your data isnt in
spatialite/postGIS, I don't know if you can do a select distinct without
creating a more complicated subquery using the expression builder. From the
console:

from collections import Counter

# get a reference to the layer to be searched
layer = iface.activeLayer()

# get the position in the attribute table of the attribute to be checked
idx = layer.fieldNameIndex('attribute_name')

# create a list of all the attribute values
attributeList = [feature.attributes()[idx] for feature in
layer.getFeatures()]

# print the duplicate entries in the attributeList
print([attribute for attribute, count in Counter(attributeList).items() if
count > 1])


Eric



On Fri, Feb 28, 2014 at 8:32 PM, Alex Mandel wrote:

> On 02/28/2014 02:46 AM, Paolo Cavallini wrote:
> > Hi all.
> > I can't recall of any function or plugin to find duplicate data ona
> > table of attributes: am I right, or am I forgetting something?
> > Thanks in advance.
> >
>
> I always use Spatialite or Postgis so I can run a DISTINCT function in a
> query, or GROUP BY what should be unique and get a count (if it's > 1
> it's not unique). I'm not aware of any other way to check for duplicate
> data.
>
> Enjoy,
> Alex
> ___
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] Set QgsVectorLayer.EditType to value map and populate value:description pairs with python

2014-01-27 Thread Eric Goddard
Thanks for the info,  Matthias. I'm using the development version of QGIS
for the relations support.  Looking forward to future updates!

Eric
On Jan 27, 2014 5:40 PM, "Matthias Kuhn"  wrote:

> Hi Eric,
>
> On Mon 27 Jan 2014 20:21:35 CET, Eric Goddard wrote:
> > Hi all,
> > And this is where I'm stuck. I can't find anything in the API docs
> > about how to set the value-description pairs. Any help would be
> > greatly appreciated!
> >
> > Thanks,
> > Eric
> >
>
> This was working in 1.8, but it's not working in 2.x releases (so far).
> You may have heard of the update to "SIP API v2". Since we did this, Qt
> objects are converted to python objects to make it more natural to use
> for developers. Before that, you could just retrieve the existing
> valuemap and edit it in place, because when you called
> layer.valueMap(idx), you would receive a reference to the map QGIS
> internally works with. However, the new SIP API converts the map you
> receive to a native python dict and creates a copy of it. And if you
> edit this copy, QGIS doesn't realize, that there are changes.
>
> So, in short: If you use 1.8, just edit the map you get back. If you
> use 2.0, I don't think there is a possibility and there won't be one in
> 2.2. However, for 2.4 there will be an update which will make this
> possible again (with a new API).
>
> Regards
> Matthias
>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

[Qgis-developer] Set QgsVectorLayer.EditType to value map and populate value:description pairs with python

2014-01-27 Thread Eric Goddard
Hi all,

I'm running QGIS Master. I would like to update a vector layer's EditType
to a ValueMap and pass in the value:description pairs using python. I
haven't ever used C++ and am having some difficulty understanding the
documentation. Through reading the documentation and trial and error I was
able to adjust the edit type to a Value map with:

vectLayer = iface.ActiveLayer()
vectLayer.setEditType(4, QgsVectorLayer.EditType(3))

where 4 is the id of the attribute I want to update and
QgsVectorLayer.EditType(3) sets the EditType to a Value Map.

And this is where I'm stuck. I can't find anything in the API docs about
how to set the value-description pairs. Any help would be greatly
appreciated!

Thanks,
Eric
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer