[QGIS-Developer] SSL certificate for feed.qgis.org

2020-05-18 Thread Rudi von Staden
Looks like the certificate for feed.qgis.org needs to be updated - it's
giving an error on startup.

[image: image.png]

Kind regards,
Rudi
___
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] issues.qgis.org is down

2020-01-09 Thread Rudi von Staden
Greetings all,

Just a heads-up that issues.qgis.org is currently down. I checked on
https://downforeveryoneorjustme.com/ and it seems it's general.

Kind regards,
Rudi
___
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] K-neighbour concave hull algorithm

2018-08-16 Thread Rudi von Staden
On Thu, 16 Aug 2018 at 10:13, Luigi Pirelli  wrote:

> I agree with  the progressive approach in your PR e.g. just integrate the
> alg as processing algorithm. A 2) approach can come later
>
> https://github.com/qgis/QGIS/pull/7626
>

Thanks Luigi. I had thought to discuss it on the list first, but it was
simple enough to prepare it as an algorithm so I just opened the PR for
option 1. I do think the C++ implementation could be worthwhile for big
datasets, but agree that it could be added later.

tnks to point out about this alg/plugin, I didn't realized it's existence...
>

Yes, I also came across it by accident when I had already started writing
my own version. It definitely saved me a lot of time to be able to reuse
the code!

Rudi
___
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] K-neighbour concave hull algorithm

2018-08-15 Thread Rudi von Staden
Hi all,

I've been using the concave hull processing algorithm as part of a model
which iterates over species distribution data to create a basic
distribution polygon. I've found that it can produce very unexpected
outputs for certain input data, so I don't think it's a good algorithm to
use 'unsupervised'.

The results from the k-neighbour concave hull algorithm (
https://www.researchgate.net/publication/220868874_Concave_hull_A_k-nearest_neighbours_approach_for_the_computation_of_the_region_occupied_by_a_set_of_points)
are generally more pleasing and will never have strange pinches or ignored
points (although it also doesn't provide for holes). From my testing I
think the outputs correspond more to how someone would naturally
circumscribe a set of points. As such I would argue for it to be included
as one of the default algorithms.

There is an existing plugin (
https://github.com/detlevn/QGIS-ConcaveHull-Plugin) which is pretty decent
but it hasn't been updated to work with QGIS3. I've also come across a C++
implementation (
https://www.codeproject.com/Articles/1201438/The-Concave-Hull-of-a-Set-of-Points)
which seems to have a lot of optimisation advantages.

I see three options:
1. Update the plugin code and streamline it as a qgis algorithm. I'd be
happy to give this a go if there's support and I think it would be
relatively straightforward.
2. Adapt the c++ implementation and add it as a native algorithm. This
would probably have significant performance advantages, but may not be
worth the effort. I'm not that confident with C++ and would at least need a
fair amount of guidance if someone else doesn't want to take it on. I did
reach out to the developer and he'd be happy for his code to be used if it
comes to that.
3. Update the plugin for QGIS3 (or at least the parts of it that I need). I
would do this anyway if we don't proceed with either of the other options.

Any thoughts?

Rudi
___
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] Running grass algorithms in threads

2018-08-15 Thread Rudi von Staden
1 output="rast_5b73f6b20afa113" --overwrite -o', 'g.region
n=-2332657.7474449594 s=-3803200.178477332 e=984393.5909882308
w=-834195.3236270341 res=92.07578930764342', 'r.stats.zonal
base=rast_5b73f6b20afa112 cover=rast_5b73f6b20afa113 method="average"
output=output2c6300f21c524e0da74e65776d6292cf --overwrite']

2018-08-15T11:48:01 INFOprocessInputs end. Commands: ['g.proj -c
proj4="+proj=aea +lat_1=-24 +lat_2=-32 +lat_0=0 +lon_0=24 +x_0=0 +y_0=0
+datum=WGS84 +units=m +no_defs"', 'r.external
input="C:\\Users\\rudi\\GIS\\Projects\\LizeSuitableHabitatModel\\HabitatModels\\3800-25.tif"
band=1 output="rast_5b73f6d1a6fa514" --overwrite -o', 'r.external
input="C:\\Users\\rudi\\GIS\\Projects\\LizeSuitableHabitatModel\\Analysis\\Data\\HS14.tif"
band=1 output="rast_5b73f6d1a6fa515" --overwrite -o', 'g.region
n=-2332657.7474449594 s=-3803200.178477332 e=984393.5909882308
w=-834195.3236270341 res=92.07578930764342']

2018-08-15T11:48:01 INFOprocessCommands end. Commands: ['g.proj -c
proj4="+proj=aea +lat_1=-24 +lat_2=-32 +lat_0=0 +lon_0=24 +x_0=0 +y_0=0
+datum=WGS84 +units=m +no_defs"', 'r.external
input="C:\\Users\\rudi\\GIS\\Projects\\LizeSuitableHabitatModel\\HabitatModels\\3800-25.tif"
band=1 output="rast_5b73f6d1a6fa514" --overwrite -o', 'r.external
input="C:\\Users\\rudi\\GIS\\Projects\\LizeSuitableHabitatModel\\Analysis\\Data\\HS14.tif"
band=1 output="rast_5b73f6d1a6fa515" --overwrite -o', 'g.region
n=-2332657.7474449594 s=-3803200.178477332 e=984393.5909882308
w=-834195.3236270341 res=92.07578930764342', 'r.stats.zonal
base=rast_5b73f6d1a6fa514 cover=rast_5b73f6d1a6fa515 method="average"
output=output744c02ef470a4ddbb2dbaaedf1bda2b0 --overwrite']

On Wed, 15 Aug 2018 at 08:16, Stefan Blumentrath 
wrote:

> Dear Rudi, Nyall,
>
> GRASS is being used on HPC systems for heavily parallelisation. So, in
> principle, the answer is yes, you can for sure run GRASS algorithms in
> parallel.
> On Linux, I often run several commands in parallel using xargs. So it
> works just fine in many cases. GRASS also has some specific python
> functions for parallel processing. See also:
> https://grasswiki.osgeo.org/wiki/Parallel_GRASS_jobs
> https://grasswiki.osgeo.org/wiki/Parallelizing_Scripts
>
> However, if GRASS algorithms can be run in parallel in this particular
> case depends.
>
> E.g., if the algorithm in question temporarily modifies the computational
> region, parallel processes can get in the way for each other.
> Also, with SQLite as DB backend writing several vector maps (and attribute
> tables) in parallel will be a problem (due to SQLite locks).
>
> In addition, if GRASS commands can be executed in parallel in the QGIS
> Processing framework is probably yet another question, depending on how
> e.g. QGIS handles data management (locations and mapsets) esp. in more
> complex workflows / models...
>
> CCing also grass-dev list for more qualified answers...
>
> Cheers
> Stefan
>
>
> -Original Message-
> From: QGIS-Developer  On Behalf
> Of Nyall Dawson
> Sent: onsdag 15. august 2018 01:10
> To: Rudi von Staden 
> Cc: qgis-developer 
> Subject: Re: [QGIS-Developer] Running grass algorithms in threads
>
> On Tue, 14 Aug 2018 at 21:43, Rudi von Staden  wrote:
> >
> > Hi all,
> >
> > The bottleneck in my script at the moment is the calculation of zonal
> stats using 'grass7:r.stats.zonal'. I thought I might speed things up by
> using QgsTask.fromFunction() or QgsProcessingAlgRunnerTask() to run these
> calculations in parallel. In my tests of both approaches the tasks seem to
> complete (task.status() == QgsTask.Complete), but the output file is only
> generated for 1 of 4 parallel tasks (the task that finishes first).
> >
> > I'm assuming this is because grass algorithms are not thread safe? Or am
> I missing something in my implementation that could make this work?
>
> I strongly suspect that grass algorithms cannot be run in parallel.
> This is why they cannot run in the background in QGIS like the native/GDAL
> algorithms can. But I'd love for confirmation about this and whether
> there's any way to make GRASS multi-thread safe.
>
> Because this is grass related (and not QGIS specific) I'd suggest asking
> on the grass mailing list, and relaying any responses back here.
>
> Nyall
>
> >
> > Thanks,
> > Rudi
> >
> >
> >
> > My code for the QgsTask approach is as below:
> >
> > def getZonal(task, habitatModelFile, cover):
> > tempFile = QgsProcessingUtils.generateTempFilename("output.tif")
> > processing.run("grass7:r.stats.zonal", {
> > 'base':habitatModelFile,
> 

[QGIS-Developer] Running grass algorithms in threads

2018-08-14 Thread Rudi von Staden
Hi all,

The bottleneck in my script at the moment is the calculation of zonal stats
using 'grass7:r.stats.zonal'. I thought I might speed things up by using
QgsTask.fromFunction() or QgsProcessingAlgRunnerTask() to run these
calculations in parallel. In my tests of both approaches the tasks seem to
complete (task.status() == QgsTask.Complete), but the output file is only
generated for 1 of 4 parallel tasks (the task that finishes first).

I'm assuming this is because grass algorithms are not thread safe? Or am I
missing something in my implementation that could make this work?

Thanks,
Rudi



My code for the QgsTask approach is as below:

def getZonal(task, habitatModelFile, cover):
tempFile = QgsProcessingUtils.generateTempFilename("output.tif")
processing.run("grass7:r.stats.zonal", {
'base':habitatModelFile,
'cover':cover,
'method':5,
'-c':False,
'-r':False,
'output':tempFile,
'GRASS_REGION_PARAMETER':None,
'GRASS_REGION_CELLSIZE_PARAMETER':0,
'GRASS_RASTER_FORMAT_OPT':'',
'GRASS_RASTER_FORMAT_META':''},context=context,feedback=algFeedback)

if task.isCanceled():
deleteFile(tempFile)
return

return tempFile

ls90Task = QgsTask.fromFunction('LS90', getZonal, habitatModelFile=hm1,
cover=ls90Layer)
QgsApplication.taskManager().addTask(ls90Task)
feedback.pushInfo("Calculating LS14 mean...")
ls14Task = QgsTask.fromFunction('LS14 ', getZonal, habitatModelFile=hm2,
cover=ls14Layer)
QgsApplication.taskManager().addTask(ls14Task)
hs90Task = QgsTask.fromFunction('HS90 ', getZonal, habitatModelFile=hm3,
cover=hs90Layer)
QgsApplication.taskManager().addTask(hs90Task)
hs14Task = QgsTask.fromFunction('HS14 ', getZonal, habitatModelFile=hm4,
cover=hs14Layer)
QgsApplication.taskManager().addTask(hs14Task)

while (len([t for t in [ls90Task.status(), ls14Task.status(),
hs90Task.status(),
hs14Task.status()] if t in [QgsTask.Running, QgsTask.Queued]])
> 0)
and not feedback.isCanceled():
sleep(1)

if feedback.isCanceled():
# some cleanup code (send task.cancel() and wait for tasks to terminate)
break

ls90Result = ls90Task.returned_values
ls14Result = ls14Task.returned_values
hs90Result = hs90Task.returned_values   # only this file exists
hs14Result = hs14Task.returned_values
___
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] How to create temporary raster destination path in script?

2018-08-13 Thread Rudi von Staden
Hi all,

I'd like to create a temporary raster file in my script, but I don't want
to add it as an output layer (it's an input to another step of the
process). Is there some tooling to create the path (e.g. to pass as output
parameters to algorithms called with processing.run) outside of using
`self.parameterAsOutputLayer`?

Using
`QgsApplication.processingRegistry().parameterType('rasterDestination')`
seemed promising, but I haven't been able to get an output path from that.

If not, I can just roll my own using os.environ['TMP'] but I would prefer
to follow the QGIS coding practices where possible.

Thanks,
Rudi
___
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] Difference in area calculation using memory vs output layer

2018-08-10 Thread Rudi von Staden
On Thu, 9 Aug 2018 at 08:39, Nyall Dawson  wrote:

> On Wed, 8 Aug 2018 at 18:06, Rudi von Staden  wrote:
>
> >
> > I did also calculate a range of zonal stats on the layer (which has only
> one multipolygon feature), but those results were consistent between output
> / memory layers.
> >
> > Is the area difference expected because of how shapefiles store geometry
> vs how they are handled by memory layers, or could there be a bug
> somewhere? Maybe this isn't the recommended way to calculate area? In case
> it matters, I'm using a custom CRS:
> >
> > "+proj=aea +lat_1=-24 +lat_2=-32 +lat_0=0 +lon_0=24 +x_0=0 +y_0=0
> +datum=WGS84 +units=m +no_defs"
>
> This may be a silly question -- but can you confirm that both layers
> are definitely in the same CRS?
>

Yes, they are both the result of an algorithm operating on the same source
layer.


> If so, I'd try exporting the two geometries to WKT and inspect for
> differences.
>

There are partial differences between the WKT. It seems that the OGR layer
drops some polygons. I also used isGeosValid() to check the validity, and
the OGR layer reported invalid geometry, while the Memory layer was valid.
I should note that the input layer has some invalid geometries (I'm using
buffer by 0 to try to clean up the geometry). I've put together a test
project and processing script to demonstrate the issue, including text
files with the WKT of the memory and ogr features. As a side-note, the
script also crashes QGIS a minute or so after running. I suspect it's
because I may have used incorrect output parameters.

https://www.dropbox.com/s/u1la8y63qlabiu4/area_test.zip?dl=0

Let me know if I should submit a bug report for this.

Rudi
___
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] QGIS builds

2018-08-10 Thread Rudi von Staden
On Wed, 8 Aug 2018 at 23:47, Nyall Dawson  wrote:

> > I have the build environment set up from scratch on a new computer, and
> I'm getting the same error building mdalprovider in the master branch
> (C:\OSGeo4W64\bin\hdf5.dll : fatal error LNK1107: invalid or corrupt file:
> cannot read at 0x2F0).
>
> I've seen this too. I haven't had time to investigate a proper fix, so
> in the meantime I just edit src/providers/mdal/CMakeLists.txt and
> remove all mention of HDF5. That gets the build working temporarily.
>

Thanks, that worked. I also encountered an issue with `synccrsdb` (MSB6006
cmd.exe exited with code -1073741515). In case anyone else comes across
that, the solution was to copy crssync.exe from 'OSGeo4W64\apps\qgis-dev'
to 'C:\OSGeo4W64\bin'. It's probably in one of the other osgeo4w packages,
but I haven't figured out which one yet.

Rudi
___
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] QGIS builds

2018-08-08 Thread Rudi von Staden
I have the build environment set up from scratch on a new computer, and I'm
getting the same error building mdalprovider in the master branch
(C:\OSGeo4W64\bin\hdf5.dll : fatal error LNK1107: invalid or corrupt file:
cannot read at 0x2F0). Is there maybe a problem with hdf5.dll from osgeo4w?
I've tried downloading the source from
https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/hdf5-1.8.11/src/
and building it, but even then I run into "CPack Error: Error when
generating package: HDF5".

Has nobody else had any issues with hdf5.dll? Are the instructions for 4.1
at https://github.com/qgis/QGIS/blob/master/INSTALL still accurate?

Kind regards,
Rudi

On Thu, 26 Jul 2018 at 10:34, Rudi von Staden  wrote:

> Hi all,
>
> I'm trying to build qgis from source, but I'm getting a linking error in
> `mdalprovider`:
>
> C:\OSGeo4W64\bin\hdf5.dll : fatal error LNK1107: invalid or corrupt file:
> cannot read at 0x2F0
>
>
> I have successfully built qgis before, so any idea why this would be
> causing a problem now?
>
> As background, I'm trying to build a particular pull request to help with
> testing. The steps I took were:
>
> 1. git fetch origin pull/7396/head:rastercalc
> 2. git checkout rastercalc
> 3. delete directory build-qgis-test-x86_64 (in QGIS/ms-windows/osgeo4w)
> 4. run configonly.bat
> 5. run OSGeo4W-dev.bat (which executes `call
> C:\Users\rudi_000\Source\Repos\QGIS\ms-windows\osgeo4w\msvc-env.bat x86_64`)
> 6. run devenv from command prompt
> 7. open qgis.sln
> 8. build
>
> I have tried cleaning and rebuilding mdalprovider, but get the same
> result. It could be that just repeating the process described above would
> resolve the issue (from point 3.), but since it takes several hours to
> build (I'm building on a pretty old laptop) I thought I'd ask in case I'm
> doing something wrong in the process.
>
> Thanks,
> Rudi
>
>
___
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] Difference in area calculation using memory vs output layer

2018-08-08 Thread Rudi von Staden
Hi all,

I'm building a script to iterate over a relatively complex processing
model. I started out using a parameterAsOutputLayer to get the result of
the algorithm, and then loaded that as a QgsVectorLayer() using the 'ogr'
provider. I then refactored that to use a 'memory:' layer instead. The
strange thing is that one of the steps in the script is to calculate the
area of the single feature produced by the algorithm, and the area result
is different when calculated from the shapefile loaded in vs calculated
directly from the memory layer. My code below:

### from output layer

habitatModelLayer = QgsVectorLayer(habitatModel,genspec,'ogr')
iterator =
habitatModelLayer.getFeatures(QgsFeatureRequest().setFilterFid(0))
feature = next(iterator)
spatialiteFeature = QgsFeature(feature) # make a copy
spatialiteFields = spatialiteLayer.fields()
spatialiteFeature.setFields(spatialiteFields)  # replace source
with destination fields
for f in spatialiteFeature.fields().names():
if f == 'm_area':
spatialiteFeature[f] = feature.geometry().area()/100  #
result 2294.51 km2

### from memory layer

habitatModelLayer = processingResult['model:zonal stats for
model_1:habitat model']
iterator = habitatModelLayer.getFeatures()# setFilterFid(0)
results in StopIteration
feature = next(iterator)
spatialiteFeature = QgsFeature(feature) # make a copy
spatialiteFields = spatialiteLayer.fields()
spatialiteFeature.setFields(spatialiteFields)  # replace source
with destination fields
for f in spatialiteFeature.fields().names():
if f ==  'm_area':
spatialiteFeature[f] = feature.geometry().area()/100 #
result 2156.43 km2

I did also calculate a range of zonal stats on the layer (which has only
one multipolygon feature), but those results were consistent between output
/ memory layers.

Is the area difference expected because of how shapefiles store geometry vs
how they are handled by memory layers, or could there be a bug somewhere?
Maybe this isn't the recommended way to calculate area? In case it matters,
I'm using a custom CRS:

"+proj=aea +lat_1=-24 +lat_2=-32 +lat_0=0 +lon_0=24 +x_0=0 +y_0=0
+datum=WGS84 +units=m +no_defs"

If this is not expected behaviour I could try to create a simpler script to
reproduce the issue.

Thanks,
Rudi
___
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] QGIS builds

2018-07-26 Thread Rudi von Staden
>
> 1. git fetch origin pull/7396/head:rastercalc
>

Sorry, I fetch from upstream, not origin.

Rudi
___
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] QGIS builds

2018-07-26 Thread Rudi von Staden
Hi all,

I'm trying to build qgis from source, but I'm getting a linking error in
`mdalprovider`:

C:\OSGeo4W64\bin\hdf5.dll : fatal error LNK1107: invalid or corrupt file:
cannot read at 0x2F0


I have successfully built qgis before, so any idea why this would be
causing a problem now?

As background, I'm trying to build a particular pull request to help with
testing. The steps I took were:

1. git fetch origin pull/7396/head:rastercalc
2. git checkout rastercalc
3. delete directory build-qgis-test-x86_64 (in QGIS/ms-windows/osgeo4w)
4. run configonly.bat
5. run OSGeo4W-dev.bat (which executes `call
C:\Users\rudi_000\Source\Repos\QGIS\ms-windows\osgeo4w\msvc-env.bat x86_64`)
6. run devenv from command prompt
7. open qgis.sln
8. build

I have tried cleaning and rebuilding mdalprovider, but get the same result.
It could be that just repeating the process described above would resolve
the issue (from point 3.), but since it takes several hours to build (I'm
building on a pretty old laptop) I thought I'd ask in case I'm doing
something wrong in the process.

Thanks,
Rudi
___
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] Updating qgis:rastercalculator to work better in models

2018-07-03 Thread Rudi von Staden
On Mon, 2 Jul 2018 at 18:30, Luigi Pirelli  wrote:
> My question (poll) is... does it make sense to patch native raster calc 
> instead of override gdal_calc limitation?
> Make sense to solve raster calculator bug only if these bugs are generic and 
> does not depend of the specific organization of the raster calculator GUI.

I've also encountered the issues using gdal_calc with non-homogenous
layers (which is why I started looking at the raster calculator).
Another reason I would like to see the native calc working is because
it runs much faster than having to wrap third-party tools. I've found
gdal is generally not too bad, but my use-case is still to build a
model and loop through it hundreds of times, so every second counts.

My feeling is that it wouldn't take much work to get the raster
calculator at least usable in the modeler at its current level of
functionality. Improving gdal_calc or implementing more powerful
operators in native raster calculator can then be a secondary, more
involved process.

Rudi
___
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] Updating qgis:rastercalculator to work better in models

2018-07-03 Thread Rudi von Staden
On Tue, 03 Jul 2018 at 12:03, Nyall Dawson  wrote:

> > Handling these three situations would improve the situation, but it's
> > still a bit clunky (and complicated for users to understand). Another
> > option would be to forego the source() names altogether, and use an a,
> > b, c notation like many of the other raster calculators do.
>
> I personally think this may be the best available approach, which
> doesn't require complex changes to the raster expression engine.


Is there a way to access the list of selected reference layers from within
the `ExpressionWidgetWrapper`? I haven't found any way to do this yet, and
if the list of layers in the widget is different from the layers that gets
passed to `QgsRasterCalculator` (like if new parameters or algorithms get
added to the model) it could lead to strange errors and user confusion. It
might then be best to return `QLineEdit` for the modeler view, like it
already is for `DIALOG_BATCH`?

Rudi
___
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] Updating qgis:rastercalculator to work better in models

2018-06-29 Thread Rudi von Staden
Hi all,

I'm trying to make some updates to qgis:rastercalculator in processing
to make it work better in models. The raster calculator evaluates
expressions based on the source file name. The problem with using this
in the model builder is that the file names are not always known up
front.

The list of layers in the expression widget are of class
QgsProcessingModelChildParameterSource, so I'm trying to figure out
how to set an appropriate source name for different situations.

1. The layer is an input parameter
In this case there's no way to know the source name up front, but it
could be approximated by lyr.parameterName(). This assumes that the
parameterName and the source name of the layer are the same. It's a
bit of a stretch, but I can't think of a better way to do it.

2. The layer is an anonymous layer output by another algorithm
In this case the name of the output file can be known for certain from
lyr.outputName(). This adds another problem though, since most
algorithms have the same outputName ('OUTPUT'). I have worked around
this by adding an incrementing number to the end of the index (i.e.
OUTPUT, OUTPUT1, OUTPUT2, etc.). It's not perfect but at least then
there would be a viable way to build expressions with multiple inputs.

3. The layer is a named output from another algorithm
If the algorithm has a named output, then the source file name would
be a predictable composite of lyr.outputChildId() and the 'Parameter
name'. I expected to get this from lyr.outputName() once set, but it
seems that outputName is not updated (it remains OUTPUT for most
algorithms). Is there some other way to get the 'Parameter name'
string from QgsProcessingModelChildParameterSource (or some other
way)?

Handling these three situations would improve the situation, but it's
still a bit clunky (and complicated for users to understand). Another
option would be to forego the source() names altogether, and use an a,
b, c notation like many of the other raster calculators do. The
challenge then is to have the layer identifiers in the expression
builder match the layer identifiers that are passed to
QgsRasterCalculator. One way to achieve this would be to have the
'Layers' list in the expression builder show only layers that are
selected as 'Reference layers'. That way, only the layers that are
passed to Raster Calculator as parameters could be included in the
expressions, and there can be a consistent referencing pattern whether
you are using it as a standalone algorithm or in a model. I'm just not
sure how to get the list of selected Reference layers from inside
ExpressionWidgetWrapper. If there's interest in reworking it in this
way and somebody can point me in the right direction I'd be happy to
give it a go.

Some background to this here: https://issues.qgis.org/issues/19302

Kind regards,
Rudi
___
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] Composer load time

2013-05-24 Thread Rudi von Staden
0.37 sec
  Start 42: qgis_openstreetmaptest
42/67 Test #42: qgis_openstreetmaptest ...   Passed   11.15 sec
  Start 43: qgis_wcsprovidertest
43/67 Test #43: qgis_wcsprovidertest .   Passed   32.08 sec
  Start 44: PyQgsApplication
44/67 Test #44: PyQgsApplication .   Passed0.83 sec
  Start 45: PyQgsFeature
45/67 Test #45: PyQgsFeature .   Passed0.58 sec
  Start 46: PyQgsGeometry
46/67 Test #46: PyQgsGeometry    Passed0.65 sec
  Start 47: PyQgsVectorLayer
47/67 Test #47: PyQgsVectorLayer .   Passed0.67 sec
  Start 48: PyQgsRasterLayer
48/67 Test #48: PyQgsRasterLayer .***Failed0.64 sec
  Start 49: PyQgsBlendModes
49/67 Test #49: PyQgsBlendModes ..***Failed1.34 sec
  Start 50: PyQgsRasterFileWriter
50/67 Test #50: PyQgsRasterFileWriter    Passed1.13 sec
  Start 51: PyQgsMemoryProvider
51/67 Test #51: PyQgsMemoryProvider ..   Passed0.57 sec
  Start 52: PyQgsDelimitedTextProvider
52/67 Test #52: PyQgsDelimitedTextProvider ...   Passed1.17 sec
  Start 53: PyQgsLogger
53/67 Test #53: PyQgsLogger ..   Passed0.28 sec
  Start 54: PyQgsCoordinateTransform
54/67 Test #54: PyQgsCoordinateTransform .   Passed0.55 sec
  Start 55: PyQgsRectangle
55/67 Test #55: PyQgsRectangle ...   Passed0.55 sec
  Start 56: PyQgsSpatialIndex
56/67 Test #56: PyQgsSpatialIndex    Passed0.52 sec
  Start 57: PyQgsComposerHtml
57/67 Test #57: PyQgsComposerHtml    Passed0.60 sec
  Start 58: PyQgsComposition
58/67 Test #58: PyQgsComposition .   Passed3.73 sec
  Start 59: PyQgsAnalysis
59/67 Test #59: PyQgsAnalysis    Passed0.54 sec
  Start 60: PyQgsComposerMap
60/67 Test #60: PyQgsComposerMap .***Failed   96.77 sec
  Start 61: PyQgsComposerEffects
61/67 Test #61: PyQgsComposerEffects .   Passed   37.31 sec
  Start 62: PyQgsSymbolLayerV2
62/67 Test #62: PyQgsSymbolLayerV2 ...***Failed0.76 sec
  Start 63: PyQgsPoint
63/67 Test #63: PyQgsPoint ...   Passed0.60 sec
  Start 64: PyQgsAtlasComposition
64/67 Test #64: PyQgsAtlasComposition    Passed  125.74 sec
  Start 65: PyQgsComposerLabel
65/67 Test #65: PyQgsComposerLabel ...   Passed0.63 sec
  Start 66: PyQgsExpression
66/67 Test #66: PyQgsExpression ..   Passed0.30 sec
  Start 67: PyQgsVectorFileWriter
67/67 Test #67: PyQgsVectorFileWriter    Passed0.56 sec

85% tests passed, 10 tests failed out of 67

Total Test time (real) = 452.13 sec

The following tests FAILED:
  9 - qgis_rasterlayertest (Failed)
 14 - qgis_rendererstest (Failed)
 16 - qgis_blendmodestest (Failed)
 25 - qgis_composermaptest (Failed)
 30 - qgis_composerhtmltest (Failed)
 32 - qgis_composerscalebartest (Failed)
 48 - PyQgsRasterLayer (Failed)
 49 - PyQgsBlendModes (Failed)
 60 - PyQgsComposerMap (Failed)
 62 - PyQgsSymbolLayerV2 (Failed)
Errors while running CTest
make: *** [test] Error 8



On Thu, May 23, 2013 at 8:15 PM, Duarte Carreira dcarre...@edia.pt wrote:

  I haven’t completely verified this but I’m convinced that when you
 define additional symbols’ folders that the composer takes more time to
 startup. Do you have this kind of folders added to the Settings?

 ** **

 Duarte

 ** **

 *De:* Rudi von Staden [mailto:rud...@gmail.com]
 *Enviada:* quinta-feira, 23 de Maio de 2013 14:52
 *Para:* qgis-developer
 *Assunto:* [Qgis-developer] Composer load time

 ** **

 Hi all,

 ** **

 Every time I load the composer (Ubuntu 12.10) it takes about 4 minutes to
 load (even starting from a blank project). Is this the general pattern, or
 is it perhaps something strange with my system?

 ** **

 Thanks,

 Rudi

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


[Qgis-developer] Composer load time

2013-05-23 Thread Rudi von Staden
Hi all,

Every time I load the composer (Ubuntu 12.10) it takes about 4 minutes to
load (even starting from a blank project). Is this the general pattern, or
is it perhaps something strange with my system?

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


Re: [Qgis-developer] Composer load time

2013-05-23 Thread Rudi von Staden
Hi

On Thu, May 23, 2013 at 3:52 PM, kimaidou kimai...@gmail.com wrote:

 I run also Ubuntu 12.10, and I have no problem with latest QGIS master nor
 with QGIS 1.8.


Thanks Michael. I should have said I am experiencing the problem on today's
master (827f2d4), but also on 1.8. I just timed it and it also takes 4
minutes.

Any suggestions for debugging?

2013/5/23 Rudi von Staden rud...@gmail.com

 Every time I load the composer (Ubuntu 12.10) it takes about 4 minutes to
 load (even starting from a blank project). Is this the general pattern, or
 is it perhaps something strange with my system?


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


Re: [Qgis-developer] Composer load time

2013-05-23 Thread Rudi von Staden
Hi,

On Thu, May 23, 2013 at 4:17 PM, Andreas Neumann a.neum...@carto.netwrote:

 Hi,

 This is definitely not normal.

 It takes less than a second with QGIS master (from last night) on my
 Windows machine - regardless if it is an empty composer or an existing one.
 This is on Windows from the OSGeo4W installer.

 Perhaps you have thousands of SVG files that need to be loaded and cached?


It's a fresh install of master, and with the 1.8 install I've just deleted
the .qgis folder to see if it's something to do with that. The result is
the same - with a blank project and without adding any layers it takes 4
minutes to load the composer. So I don't see how it could be caching SVG
files.

Could there be some libraries that composer needs which I don't have
installed? Composer seems to work fine though when it loads, so it's a
strange issue. There are no messages to stdout when I run it from the
command line, but are there some error logs I could check?


On Thu, 23 May 2013 15:51:46 +0200, Rudi von Staden wrote:

 Hi all,

 Every time I load the composer (Ubuntu 12.10) it takes about 4 minutes
 to load (even starting from a blank project). Is this the general
 pattern, or is it perhaps something strange with my system?

 Thanks,
 Rudi


 --
 --
 Andreas Neumann
 Böschacherstrasse 10A
 8624 Grüt (Gossau ZH)
 Switzerland

 __**_
 Qgis-developer mailing list
 Qgis-developer@lists.osgeo.org
 http://lists.osgeo.org/**mailman/listinfo/qgis-**developerhttp://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] Scattergram plugin - working?

2013-05-13 Thread Rudi von Staden
I would like to implement a plugin for identifying environmental outliers
in point data, and I thought the scattergram plugin would be a useful
starting point. I have installed PyQwt, but both versions of the
scattergram plugin crash QGIS on my system (Ubuntu 12.10, PyQt4 v.4.9.3-4,
PyQwt5 v.5.2.1). Tested on QGIS 1.8 and master.

I'm assuming this is tied to problems with PyQwt5, but before I dig too
deep, I thought I'd check if anyone else is having problems with the plugin?

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


Re: [Qgis-developer] Logo Update

2013-05-01 Thread Rudi von Staden
On Tue, Apr 30, 2013 at 1:11 PM, Nathan Woodrow madman...@gmail.com wrote:

 Please let me know if you have any feedback you would like me to leave on
 the designs at
 http://99designs.com.au/logo-design/contests/qgis-needs-logo-210397


My vote would go for #336, which I think has a better balance than #338.
I'd prefer to see it in a darker grey or black though, and maybe try
different fonts for the GIS part.

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


[Qgis-developer] Rendering order for canvas vertices

2013-05-01 Thread Rudi von Staden
Is there some way to change the rendering order of elements on the canvas?
In a plugin I'm working on, I have a large number of vertices implemented
with QgsVertexMarker(). As the user selects different vertices, the colour
changes from green to red. This all works fine, but it sometimes happens
that one vertex is hidden behind another one nearby, and in these cases you
can't see the red vertex on the map (see http://snag.gy/9fB5s.jpg for
example).

Is there some way to change the rendering order of a vertex to bring it to
the top?

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


Re: [Qgis-developer] Possible improvement | Actions on right click

2013-03-14 Thread Rudi von Staden
+1 for right-click actions. Also it would be useful if plugins could add
actions to the right-click menu.

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


[Qgis-developer] A faster update than mapCanvas().refresh()?

2013-03-11 Thread Rudi von Staden
I have a whole bunch of markers (QgsVertexMarker), and I'm trying to
highlight the active one when the selection in a list changes. To do this I
make the active marker red, while the others are green. However, in order
for the new colour to be visible, I have to do a mapCanvas().refresh(),
which takes about a second. The idea is that it should be quick and easy to
scroll through the markers, so it's quite annoying that it takes so long to
just change the colour. Is there some other way to update just the marker
itself? I see there is a paint(QPainter) method for QgsVertexMarker - is
there some way to use that?

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


[Qgis-developer] Uploading plugin

2013-02-27 Thread Rudi von Staden
I think my Distribution Map Generator plugin (
https://github.com/rudivs/DistroMap) is at a stage where it can be added to
the plugin registry for those who would find it useful. I tried doing so
via http://plugins.qgis.org/plugins/add/, but it gave the following error:


Error 500: internal application error.

An email message with all error details has been sent to our staff that
will fix the issue ASAP.


I'm not sure if I'm adding it in the wrong place, or if I should try again
later? I set up the framework using Plugin Builder, so is the included
'plugin_upload.py' script the recommended way to share the plugin?

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


Re: [Qgis-developer] Unloading a layer in Sextante script crashes QGIS

2013-02-21 Thread Rudi von Staden
I got the script to work using
QgsMapLayerRegistry.instance().addMapLayer(taxon_layer) to load and

QgsMapLayerRegistry.instance().removeMapLayers([taxon_layer.id()]) to
remove the layer. The main error was that the remove command needs the
layer id in a list.


I also made a plugin out of it, so if anyone would find it useful it's at
https://github.com/rudivs/DistroMap. I must say that writing it first as a
Sextante script was a great help in working out the logic. I could then
look at the code from the algorithms and adapt it to my purposes.

Regards,
Rudi


On Tue, Feb 19, 2013 at 2:10 PM, Rudi von Staden rud...@gmail.com wrote:

 Thanks Victor... I tried a few other ways to load the layer, but none of
 them seem to work.



 On Tue, Feb 19, 2013 at 1:13 PM, Victor Olaya vola...@gmail.com wrote:

 ...

  Ideally, a SEXTANTE algorithm should just take data and produce new
 data, and then, if it is declared correctly as algorithm output, it
 will be loaded automatically by SEXTANTE. I am afraid that your
 algorithm might go beyond what SEXTANTE expects

 Anyway, the problem might be that you are trying to remove the layer
 and maybe it is not there since the load method in SEXTANTE does not
 add the layer to the canvas, but just open it so SEXTANTE algorithms
 can use it if it is not loaded.
 ...

 2013/2/19 Rudi von Staden rud...@gmail.com:
  I've put together a Sextante script to automate the production of
 grid-based
  species distribution maps (png image output) by modifying [1] and [2].
 It
  takes a vector layer of point localities (with species name as a field)
 and
  a grid layer as input, and produces output maps by selecting grids
 based on
  point localities.
 
  For each species it creates a distribution shapefile, which consists of
 the
  grid polygons where the species occurs. As far as I could tell, this
 layer
  needs to be loaded to the canvas before it can be included in the
 layerset
  to be rendered for the output images (is there a better way?). Sextante
  includes a function for loading layers, but not removing them. From
 what I
  could find,
  QgsMapLayerRegistry.instance().removeMapLayers(taxon_layer.id())
 should
  remove the layer, but it crashes QGIS when I try (current git version).
 If I
  comment out the line, my canvas gets clogged. Any idea where the problem
  lies? Script below.
 
  Thanks,
  Rudi
 
  [1] http://www.qgis.org/pyqgis-cookbook/composer.html#simple-rendering
  [2]
 http://qgissextante.blogspot.com/2013/01/using-selection-algorithms.html
 
 
  #Definition of inputs and outputs
  #==
  ##[Scratch]=group
  ##all_localities=vector
  ##taxon_field=field all_localities
  ##africa_map=vector
  ##sa_map=vector
  ##grid_layer=vector
  ##distribution_style_file=file
  ##output=output file
 
  #Algorithm body
  #==
  from qgis.core import *
  from PyQt4.QtCore import *
  from PyQt4.QtGui import *
  from sextante.core.QGisLayers import QGisLayers
  from sextante.core.SextanteVectorWriter import SextanteVectorWriter
  import tempfile
  import os
 
  def print_map(taxon,taxon_shp):
  #load taxon layer (necessary?)
  QGisLayers.load(taxon_shp,name = taxon,style =
  distribution_style_file)
 
  # create image (dimensions 325x299)
  img = QImage(QSize(325,299), QImage.Format_ARGB32_Premultiplied)
 
  # set image's background color
  color = QColor(192,192,255)   # blue sea
  img.fill(color.rgb())
 
  # create painter
  p = QPainter()
  p.begin(img)
  p.setRenderHint(QPainter.Antialiasing)
 
  render = QgsMapRenderer()
 
  # create layer set
  africa_layer = QGisLayers.getObjectFromUri(africa_map)
  sa_layer = QGisLayers.getObjectFromUri(sa_map)
  taxon_layer = QGisLayers.getObjectFromUri(taxon_shp)
 
  lst = []
  lst.append(taxon_layer.id())
  lst.append(sa_layer.id())
  lst.append(africa_layer.id())
 
  render.setLayerSet(lst)
 
  # set extent (xmin,ymin,xmax,ymax)
  rect = QgsRectangle(14.75,-36.00,34.00,-21.00)
  render.setExtent(rect)
 
  # set output size
  render.setOutputSize(img.size(), img.logicalDpiX())
 
  # do the rendering
  render.render(p)
  p.end()
 
  # save image
  outdir = os.path.dirname(os.path.abspath(output))
  img.save(os.path.join(outdir,taxon+.png),png)
 
  # remove taxon layer from project
  QgsMapLayerRegistry.instance().removeMapLayers(taxon_layer.id())
  #crashes QGIS
 
  tempdir = tempfile.gettempdir()
  taxa = sextante.runalg('qgis:listuniquevalues', all_localities,
 taxon_field,
  None)['UNIQUE_VALUES'].split(;)
  counter = 0   # limit for testing
  for taxon in taxa:
  if counter  10:
  sextante.runalg('qgis:selectbyattribute', all_localities,
  taxon_field, 0, taxon)
  sextante.runalg('qgis:selectbylocation', grid_layer,
 all_localities,
  0)
  filename = os.path.join(tempdir,taxon.shp)#memory file
 better

[Qgis-developer] Unloading a layer in Sextante script crashes QGIS

2013-02-19 Thread Rudi von Staden
I've put together a Sextante script to automate the production of
grid-based species distribution maps (png image output) by modifying [1]
and [2]. It takes a vector layer of point localities (with species name as
a field) and a grid layer as input, and produces output maps by selecting
grids based on point localities.

For each species it creates a distribution shapefile, which consists of the
grid polygons where the species occurs. As far as I could tell, this layer
needs to be loaded to the canvas before it can be included in the layerset
to be rendered for the output images (is there a better way?). Sextante
includes a function for loading layers, but not removing them. From what I
could find, QgsMapLayerRegistry.instance().removeMapLayers(taxon_layer.id())
should remove the layer, but it crashes QGIS when I try (current git
version). If I comment out the line, my canvas gets clogged. Any idea where
the problem lies? Script below.

Thanks,
Rudi

[1] http://www.qgis.org/pyqgis-cookbook/composer.html#simple-rendering
[2] http://qgissextante.blogspot.com/2013/01/using-selection-algorithms.html


#Definition of inputs and outputs
#==
##[Scratch]=group
##all_localities=vector
##taxon_field=field all_localities
##africa_map=vector
##sa_map=vector
##grid_layer=vector
##distribution_style_file=file
##output=output file

#Algorithm body
#==
from qgis.core import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from sextante.core.QGisLayers import QGisLayers
from sextante.core.SextanteVectorWriter import SextanteVectorWriter
import tempfile
import os

def print_map(taxon,taxon_shp):
#load taxon layer (necessary?)
QGisLayers.load(taxon_shp,name = taxon,style =
distribution_style_file)

# create image (dimensions 325x299)
img = QImage(QSize(325,299), QImage.Format_ARGB32_Premultiplied)

# set image's background color
color = QColor(192,192,255)   # blue sea
img.fill(color.rgb())

# create painter
p = QPainter()
p.begin(img)
p.setRenderHint(QPainter.Antialiasing)

render = QgsMapRenderer()

# create layer set
africa_layer = QGisLayers.getObjectFromUri(africa_map)
sa_layer = QGisLayers.getObjectFromUri(sa_map)
taxon_layer = QGisLayers.getObjectFromUri(taxon_shp)

lst = []
lst.append(taxon_layer.id())
lst.append(sa_layer.id())
lst.append(africa_layer.id())

render.setLayerSet(lst)

# set extent (xmin,ymin,xmax,ymax)
rect = QgsRectangle(14.75,-36.00,34.00,-21.00)
render.setExtent(rect)

# set output size
render.setOutputSize(img.size(), img.logicalDpiX())

# do the rendering
render.render(p)
p.end()

# save image
outdir = os.path.dirname(os.path.abspath(output))
img.save(os.path.join(outdir,taxon+.png),png)

# remove taxon layer from project
QgsMapLayerRegistry.instance().removeMapLayers(taxon_layer.id())
#crashes QGIS

tempdir = tempfile.gettempdir()
taxa = sextante.runalg('qgis:listuniquevalues', all_localities,
taxon_field, None)['UNIQUE_VALUES'].split(;)
counter = 0   # limit for testing
for taxon in taxa:
if counter  10:
sextante.runalg('qgis:selectbyattribute', all_localities,
taxon_field, 0, taxon)
sextante.runalg('qgis:selectbylocation', grid_layer,
all_localities, 0)
filename = os.path.join(tempdir,taxon.shp)#memory file better?
sextante.runalg('qgis:saveselectedfeatures', grid_layer, filename)
print_map(taxon,filename)
counter+=1
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] Unloading a layer in Sextante script crashes QGIS

2013-02-19 Thread Rudi von Staden
Thanks Victor... I tried a few other ways to load the layer, but none of
them seem to work.

Another approach would be to somehow render the layer without loading it to
the canvas first. Is it possible to add a layer to a QgsMapRenderer() layer
set without it being loaded in the project's QgsMapLayerRegistry? I guess
not since it requires a layer id, which I guess is provided by the
registry. Is it possible to have more than one QgsMapLayerRegistry? If it
is, I could create an output registry for each map... if not, looks like
I'll need to make a full plugin.

Thanks,
Rudi


On Tue, Feb 19, 2013 at 1:13 PM, Victor Olaya vola...@gmail.com wrote:

 Interacting with the canvas or any other elements in QGIS is not a
 good idea from SEXTANTE. It might cause that freezing you mention,
 since you are calling GUI methods from a different thread and that
 might result in strange behaviour.

 Ideally, a SEXTANTE algorithm should just take data and produce new
 data, and then, if it is declared correctly as algorithm output, it
 will be loaded automatically by SEXTANTE. I am afraid that your
 algorithm might go beyond what SEXTANTE expects

 Anyway, the problem might be that you are trying to remove the layer
 and maybe it is not there since the load method in SEXTANTE does not
 add the layer to the canvas, but just open it so SEXTANTE algorithms
 can use it if it is not loaded.

 Hope this helps

 2013/2/19 Rudi von Staden rud...@gmail.com:
  I've put together a Sextante script to automate the production of
 grid-based
  species distribution maps (png image output) by modifying [1] and [2]. It
  takes a vector layer of point localities (with species name as a field)
 and
  a grid layer as input, and produces output maps by selecting grids based
 on
  point localities.
 
  For each species it creates a distribution shapefile, which consists of
 the
  grid polygons where the species occurs. As far as I could tell, this
 layer
  needs to be loaded to the canvas before it can be included in the
 layerset
  to be rendered for the output images (is there a better way?). Sextante
  includes a function for loading layers, but not removing them. From what
 I
  could find,
  QgsMapLayerRegistry.instance().removeMapLayers(taxon_layer.id())
 should
  remove the layer, but it crashes QGIS when I try (current git version).
 If I
  comment out the line, my canvas gets clogged. Any idea where the problem
  lies? Script below.
 
  Thanks,
  Rudi
 
  [1] http://www.qgis.org/pyqgis-cookbook/composer.html#simple-rendering
  [2]
 http://qgissextante.blogspot.com/2013/01/using-selection-algorithms.html
 
 
  #Definition of inputs and outputs
  #==
  ##[Scratch]=group
  ##all_localities=vector
  ##taxon_field=field all_localities
  ##africa_map=vector
  ##sa_map=vector
  ##grid_layer=vector
  ##distribution_style_file=file
  ##output=output file
 
  #Algorithm body
  #==
  from qgis.core import *
  from PyQt4.QtCore import *
  from PyQt4.QtGui import *
  from sextante.core.QGisLayers import QGisLayers
  from sextante.core.SextanteVectorWriter import SextanteVectorWriter
  import tempfile
  import os
 
  def print_map(taxon,taxon_shp):
  #load taxon layer (necessary?)
  QGisLayers.load(taxon_shp,name = taxon,style =
  distribution_style_file)
 
  # create image (dimensions 325x299)
  img = QImage(QSize(325,299), QImage.Format_ARGB32_Premultiplied)
 
  # set image's background color
  color = QColor(192,192,255)   # blue sea
  img.fill(color.rgb())
 
  # create painter
  p = QPainter()
  p.begin(img)
  p.setRenderHint(QPainter.Antialiasing)
 
  render = QgsMapRenderer()
 
  # create layer set
  africa_layer = QGisLayers.getObjectFromUri(africa_map)
  sa_layer = QGisLayers.getObjectFromUri(sa_map)
  taxon_layer = QGisLayers.getObjectFromUri(taxon_shp)
 
  lst = []
  lst.append(taxon_layer.id())
  lst.append(sa_layer.id())
  lst.append(africa_layer.id())
 
  render.setLayerSet(lst)
 
  # set extent (xmin,ymin,xmax,ymax)
  rect = QgsRectangle(14.75,-36.00,34.00,-21.00)
  render.setExtent(rect)
 
  # set output size
  render.setOutputSize(img.size(), img.logicalDpiX())
 
  # do the rendering
  render.render(p)
  p.end()
 
  # save image
  outdir = os.path.dirname(os.path.abspath(output))
  img.save(os.path.join(outdir,taxon+.png),png)
 
  # remove taxon layer from project
  QgsMapLayerRegistry.instance().removeMapLayers(taxon_layer.id())
  #crashes QGIS
 
  tempdir = tempfile.gettempdir()
  taxa = sextante.runalg('qgis:listuniquevalues', all_localities,
 taxon_field,
  None)['UNIQUE_VALUES'].split(;)
  counter = 0   # limit for testing
  for taxon in taxa:
  if counter  10:
  sextante.runalg('qgis:selectbyattribute', all_localities,
  taxon_field, 0, taxon)
  sextante.runalg('qgis:selectbylocation', grid_layer

[Qgis-developer] Keeping up with latest Sextante developments

2012-10-27 Thread Rudi von Staden
Hi all,

There's quite a bit of activity on the Sextante plugin, and I'd like to
keep up with the latest developments. It seems things have changed recently
so I have a couple of questions about the best approach:

1) As far as I can tell, active development is now happening on GitHub QGIS
core rather than svn; if I fork the QGIS repo, can I use just the sextante
plugin with old faithful QGIS 1.8.0, or could I run into conflicts?

2) I am encountering quite a few bugs which are relatively easy to fix. If
I do so, should I log them on hub.qgis.org and supply a patch, or is it
better to initiate a pull request on GitHub?

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


[Qgis-developer] Getting Sextante from GitHub core to work with QGIS 1.8.0

2012-10-27 Thread Rudi von Staden
I have cloned the GitHub repo, and have symbolically linked the
~/.qgis/python/plugins/sextante directory to
Quantum-GIS/python/plugins/sextante.

When I load QGIS, it does give me an error, stemming from
sextante/about/AboutDialog.py; in particular, 'from ui_aboutdialogbase
import Ui_DlgAbout' produces an ImportError (No module named
ui_aboutdialogbase).

I imagine this should be provided by PyQt
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] Getting Sextante from GitHub core to work with QGIS 1.8.0

2012-10-27 Thread Rudi von Staden
Sorry, accidentally hit the send button too early.

On Sat, Oct 27, 2012 at 4:00 PM, Rudi von Staden rud...@gmail.com wrote:

 I have cloned the GitHub repo, and have symbolically linked the
 ~/.qgis/python/plugins/sextante directory to
 Quantum-GIS/python/plugins/sextante.

 When I load QGIS, it does give me an error, stemming from
 sextante/about/AboutDialog.py; in particular, 'from ui_aboutdialogbase
 import Ui_DlgAbout' produces an ImportError (No module named
 ui_aboutdialogbase).

 I imagine this should be provided by PyQt


I imagine this should be provided by PyQt4.QtGui? Am I using an outdated
version? I'm using python-qt4 | 4.9.1-2ubuntu1 from precise/main. Here's
the full error message on load:


==[paste]==

Couldn't load plugin sextante due an error when calling its classFactory()
method

Traceback (most recent call last):
  File /usr/lib/python2.7/dist-packages/qgis/utils.py, line 164, in
startPlugin
plugins[packageName] = package.classFactory(iface)
  File /home/rudi/.qgis//python/plugins/sextante/__init__.py, line 45, in
classFactory
from sextante.SextantePlugin import SextantePlugin
  File /usr/lib/python2.7/dist-packages/qgis/utils.py, line 309, in
_import
mod = _builtin_import(name, globals, locals, fromlist, level)
  File /home/rudi/.qgis//python/plugins/sextante/SextantePlugin.py, line
45, in
from sextante.about.AboutDialog import AboutDialog
  File /usr/lib/python2.7/dist-packages/qgis/utils.py, line 309, in
_import
mod = _builtin_import(name, globals, locals, fromlist, level)
  File /home/rudi/.qgis//python/plugins/sextante/about/AboutDialog.py,
line 32, in
from ui_aboutdialogbase import Ui_DlgAbout
  File /usr/lib/python2.7/dist-packages/qgis/utils.py, line 309, in
_import
mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named ui_aboutdialogbase

Python version:
2.7.3 (default, Aug  1 2012, 05:27:35)
[GCC 4.6.3]


QGIS version:
1.8.0-Lisboa Lisboa, exported

Python path: ['/usr/share/qgis/python', '/home/rudi/.qgis//python',
'/home/rudi/.qgis//python/plugins', '/usr/share/qgis/python/plugins',
'/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/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-couch',
'/usr/lib/python2.7/dist-packages/ubuntuone-installer',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
'/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] Getting Sextante from GitHub core to work with QGIS 1.8.0

2012-10-27 Thread Rudi von Staden
Okay, I see I'll have to figure out CMake... Is there an easy way to build
just the sextante plugin, or do I have to build the whole QGIS system?

On Sat, Oct 27, 2012 at 4:04 PM, Rudi von Staden rud...@gmail.com wrote:


 On Sat, Oct 27, 2012 at 4:00 PM, Rudi von Staden rud...@gmail.com wrote:

 I have cloned the GitHub repo, and have symbolically linked the
 ~/.qgis/python/plugins/sextante directory to
 Quantum-GIS/python/plugins/sextante.

 When I load QGIS, it does give me an error, stemming from
 sextante/about/AboutDialog.py; in particular, 'from ui_aboutdialogbase
 import Ui_DlgAbout' produces an ImportError (No module named
 ui_aboutdialogbase).



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


Re: [Qgis-developer] Getting Sextante from GitHub core to work with QGIS 1.8.0

2012-10-27 Thread Rudi von Staden
Thanks, that did the trick. I can see that building the full QGIS would
make sense though, so I'll get my build environment set up to do that. For
now it's good to know how to just compile sextante though.

Thanks,
Rudi


On Sat, Oct 27, 2012 at 5:21 PM, Alexander Bruy alexander.b...@gmail.comwrote:

 As Victor said, you only need to compile resource file and some dialogs
 (currently only About dialog). Just run commands

 pyrcc4 -o /path/to/sextante/resources_rc.py /path/to/sextante/resources.qrc
 pyuic4 -o /path/to/sextante/about/ui_aboutdialogbase.py
 /path/to/sextante/about/aboutdialogbase.ui

 You can create custom makefile that will do this for you.

 But note that I plan to move all SEXTANTE dialogs to .ui files because
 this simlifies maintenance and makes code cleaner. So maybe it is
 better to build full QGIS. Now python plugins correctly loaded from
 build dir. So you can symlink SEXTANTE from output directory to your
 main QGIS plugin dir.

 2012/10/27 Victor Olaya vola...@gmail.com:
  You do not actually have to build SEXTANTE, just a couple of GUI files
  (the about dialog and a resources file). I guess Alex can give you
  better advise in this, since he introduced that changed. Until that, I
  was doing the GUI files directly without using the pyQt tools (not the
  optimal way, I guess...), so no build was needed, but now you need it
  to get the .py files from the resource files.
 
  You have to use pyrcc4 and pyuic4 to compile those files. I guess you
  can do it manually if you do not want to build using CMake
 
  Best
 
  Victor

 --
 Alexander Bruy

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