Martin-Jung / LecoS

LecoS QGis Plugin - Contains several analytical functions for land cover analysis
GNU General Public License v3.0
21 stars 19 forks source link

Batching though classes is inefficient #3

Closed lselzer closed 5 years ago

lselzer commented 8 years ago

Hello, I have been using your software and it works great. Thanks for making it.

I would like to calculate some metrics for all the classes and right now it would very very slow because I have over 50000 polygons. I have profiled the go() function in BatchConverterclass and a third of the time is consumed by numpy.choose() in getClipArray(). Since this is same for each class inside the polygon it would be faster to loop through the desired classes after the clipping is done. I'm willing to do it as it would be rather easy, although I might need help with qgis gui interface. What do you think?

Martin-Jung commented 8 years ago

And thanks for pointing at the speed fix. Incorporated!

Generally speed is dependent on numpy and PIL array subsetting mechanisms and other than reordering as you suggested there is not much to do for speed improvement. When I programmed the functions I had small "landscape"-sized arrays in mind. Speed was never an issue. Furthermore I programmed the tool in order to quantify landscape metrics for individual classes seperately and not for a whole thematic landcover map in one go.

Also before you adapt or rewrite the code, consider: Wouldn't it be easier and faster for you if you split your class raster into multiple single mini-tifs temporarlly for the analysis ? (even if their are over 50.000). I am currently doing the same by subsetting my array (split into tiles / areas of interest) on a cluster before feeding it to LecoS.

lselzer commented 8 years ago

Thanks for the tip, it worked. I don't know why but splitting the shape into less than 5000 polygons each made it orders fo magnitude faster.

DuarteAndre commented 8 years ago

Hello,

First of all congratulations and thanks for LecoS. I have used the Lecos and has even compared with FRAGSTATS and Patch analyst. I have good results. I would like to help improve the module with more metrics at the landscape level. I will try program some metrics and send you.

Best regards

André Duarte

Martin-Jung commented 5 years ago

Closed for now. Feel free to reopen if something changes