Error "Random points from classification"
moin,
bekomme beim obigen Tool folgenden Fehler im log, verstehe ihn aber nicht. (Nebenbei: das TIFF wurde nicht in der Enmapbox gerechnet)
2021-12-10T14:48:44 CRITICAL Traceback (most recent call last):
File "C:/Users//AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\enmapboxgeoalgorithms\provider.py", line 155, in processAlgorithm
result = self.processAlgorithm_()
File "C://AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\enmapboxgeoalgorithms\algorithms.py", line 2085, in processAlgorithm_
progressBar=self._progressBar)
File "C://AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\hubflow\core.py", line 3026, in fromRandomPointsFromClassification
filename=filename)
File "C://AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\hubflow\core.py", line 55, in apply
overwrite=self.kwargs.get('overwrite', True), *ufuncArgs, **ufuncKwargs)
File "C://AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\hubdc\applier.py", line 979, in apply
results = self._runProcessSubgrids()
File "C://AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\hubdc\applier.py", line 1048, in _runProcessSubgrids
result = self.operatorType.aggregate(blockResults=blockResults, grid=self.grid(), *self.ufuncArgs, **self.ufuncKwargs)
File "C://AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\hubflow\core.py", line 3197, in aggregate
indicisi = indicis[id == i + 1]
IndexError: boolean index did not match indexed array along dimension 0; dimension is 292979342 but corresponding boolean dimension is 564240495
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users//AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\enmapboxgeoalgorithms\provider.py", line 169, in processAlgorithm
raise Exception('unexpected error')
Exception: unexpected error
Comments (16)
-
-
reporter Can’t find this o.O
-
Please make sure that you use the latest version:
-
reporter IConsole command:
>>>qgis_process run enmapbox:RandomPointsFromCategorizedRasterLayer --stratification=/home/eike/Desktop/Segeberg/klassifikationen/reclassified.vrt n=30 distanceGlobal=0 distanceStatum=0 outputPoints=TEMPORARY_OUTPUT
Traceback (most recent call last):
File "/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/site-packages/typeguard/__init__.py", line 903, in wrapper
retval = func(*args, **kwargs)
File "/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapboxprocessing/algorithm/randompointsfromcategorizedrasteralgorithm.py", line 158, in processAlgorithm
writer = driver.createFromArray(arrayStrata, stratification.extent(), stratification.crs())
File "/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/site-packages/typeguard/__init__.py", line 903, in wrapper
retval = func(*args, **kwargs)
File "/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapboxprocessing/driver.py", line 75, in createFromArray
dataType = Utils.numpyDataTypeToQgisDataType(array[0].dtype)
File "/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/site-packages/typeguard/__init__.py", line 903, in wrapper
retval = func(*args, **kwargs)
File "/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapboxprocessing/utils.py", line 128, in numpyDataTypeToQgisDataType
raise Exception(f'unsupported data type: {dataType}')
Exception: unsupported data type: int64Execution failed after 844.76 seconds (14 minutes 5 seconds)
-
Looks like the int64 data type causes problems.
- You can save your classification as int32, which should solve the problem.
- Please share your classification file, so that I can reproduce the error.
-
reporter I already tried data type conversion, it gives me out the same error message.
https://www.dropbox.com/s/idjfyhy2p1vf8hz/all_features_Cnv.tif?dl=0
-
- Your raster has two bands. I took the first band and categorized it (use Layer Property >Symbology).
2. Now you can draw random points:
Unfortunately, with your data, it took me 2 minutes to draw 10 points per class. Drawing 1000 points in total takes about 30 minutes. So be prepared to wait a bit.
I definetly need to investigate, why this is so slow:
follow-up issue #880
-
reporter as already mentioned, it’s not working for me, even not if I convert the data type.
QGIS version: 3.22.1-Białowieża
QGIS code revision: 663dcf8fb9
Qt version: 5.12.8
Python version: 3.8.10
GDAL version: 3.0.4
GEOS version: 3.8.0-CAPI-1.13.1
PROJ version: Rel. 6.3.1, February 10th, 2020
PDAL version: 2.0.1 (git-version: Release)
Algorithm started at: 2021-12-14T14:33:04
Algorithm 'Random points from categorized raster layer' starting…
Input parameters:
{ 'distanceGlobal' : 0, 'distanceStatum' : 0, 'n' : '10', 'outputPoints' : 'TEMPORARY_OUTPUT', 'seed' : None, 'stratification' : '/tmp/processing_kzygtl/d36acbde676b49a6a973c3056f63ff81/outputTranslatedRaster.tif' }
Python command:
>>>processing.run('enmapbox:RandomPointsFromCategorizedRasterLayer', dict(stratification='/tmp/processing_kzygtl/d36acbde676b49a6a973c3056f63ff81/outputTranslatedRaster.tif', n='10', distanceGlobal=0, distanceStatum=0, outputPoints='TEMPORARY_OUTPUT'))
Console command:
>>>qgis_process run enmapbox:RandomPointsFromCategorizedRasterLayer --stratification=/tmp/processing_kzygtl/d36acbde676b49a6a973c3056f63ff81/outputTranslatedRaster.tif n=10 distanceGlobal=0 distanceStatum=0 outputPoints=TEMPORARY_OUTPUT
Traceback (most recent call last):
File "/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/site-packages/typeguard/__init__.py", line 903, in wrapper
retval = func(*args, **kwargs)
File "/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapboxprocessing/algorithm/randompointsfromcategorizedrasteralgorithm.py", line 158, in processAlgorithm
writer = driver.createFromArray(arrayStrata, stratification.extent(), stratification.crs())
File "/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/site-packages/typeguard/__init__.py", line 903, in wrapper
retval = func(*args, **kwargs)
File "/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapboxprocessing/driver.py", line 75, in createFromArray
dataType = Utils.numpyDataTypeToQgisDataType(array[0].dtype)
File "/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/site-packages/typeguard/__init__.py", line 903, in wrapper
retval = func(*args, **kwargs)
File "/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapboxprocessing/utils.py", line 128, in numpyDataTypeToQgisDataType
raise Exception(f'unsupported data type: {dataType}')
Exception: unsupported data type: int64Execution failed after 273.12 seconds (4 minutes 33 seconds)
Loading resulting layers
Algorithm 'Random points from categorized raster layer' finished
-
What are your categories? Are you using those?:
-
reporter yip
-
Alright, not sure why this happens on your system, it’s probably Linux related.
Anyways, here is a workaround that you can try for now:
Edit this line:
/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapboxprocessing/algorithm/randompointsfromcategorizedrasteralgorithm.py", line 158, in processAlgorithm
To:
writer = driver.createFromArray(arrayStrata.astype(np.int32), stratification.extent(), stratification.crs())
Restart QGIS and try again.
-
reporter Console command:
>>>qgis_process run enmapbox:RandomPointsFromCategorizedRasterLayer --stratification=/home/eike/Desktop/Segeberg/klassifikationen/all_features_Cnv.tif n=10 distanceGlobal=0 distanceStatum=0 outputPoints=TEMPORARY_OUTPUT
Traceback (most recent call last):
File "/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/site-packages/typeguard/__init__.py", line 903, in wrapper
retval = func(*args, **kwargs)
File "/home/eike/.local/share/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapboxprocessing/algorithm/randompointsfromcategorizedrasteralgorithm.py", line 158, in processAlgorithm
writer = driver.createFromArray(arrayStrata.astype(np.int32), stratification.extent(), stratification.crs())
AttributeError: 'list' object has no attribute 'astype'Execution failed after 264.38 seconds (4 minutes 24 seconds)
-
Sorry, didn’t testet it, this should work:
writer = driver.createFromArray(np.array(arrayStrata).astype(np.int32), stratification.extent(), stratification.crs()) -
reporter Finally got my points. Thanks for your always fast help advices
-
-
- changed status to resolved
- Log in to comment
Please try this algorithm: