[Qgis-user] Calculate intersecting area of two layers in a virtual field. Context of @geometry in overlay_intersects()

2024-04-05 Thread Bruno Streit via QGIS-User
Hi Klaus
Thanks a lot, works pefect! collect_gemetries() and the other way around did 
the trick.
Thanks also for the hint with the geometry generator.
Bruno

> Date: Thu, 4 Apr 2024 12:01:21 +
> From: Klaus Affeldt 
> To: "qgis-user@lists.osgeo.org" 
> Subject: [Qgis-user] Calculate intersecting area of two layers in a
>   virtual field. Context of @geometry in overlay_intersects()
> Message-ID: <5bcb1461d75f470bb86c03fc07b2c...@ansperger.de>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> Hello Bruno,
> 
> try it the other way around:
> 
> coalesce(
>   area(
> intersection(
>   @geometry, 
>   collect_geometries(
> overlay_intersects(
>   'forest',
>   @geometry
> )
>   )
> )
>   ),
>   0
> )
> 
> In addition you can use the inner part in the geometry generator.
> So you have a visual help to compare your results:
> 
> intersection(
>   @geometry, 
>   collect_geometries(
> overlay_intersects(
>   'forest',
>   @geometry
> )
>   )
> )
> 
> Mit freundlichen Gr??en
> 
> Ihre PV ANSPERGER mbH
> Klaus Affeldt
> 
> Zentrale Kamp-Lintfort
> S?dstra?e 25
> 47475 Kamp-Lintfort
> Tel. +49 2842 9635-14
> https://www.ansperger.de
> 
> A==
> >> 
> >> Dear list
> >> 
> >> Great, how powerful expressions are in QGIS!
> >> I have two polygon layers, one with parcels and one with forests. In a 
> >> virtual field of the layer parcels I'm trying to calculate the area 
> >> covered with forest. I can sum the area of intersecting forests in a 
> >> virtual field with the follwing expression:
> >> 
> >> coalesce( 
> >>   array_sum( 
> >> overlay_intersects(
> >>   layer:= 'forest', 
> >>   expression:= area(@geometry)
> >> )
> >>   )
> >> , 0)
> >> 
> >> But @geometry doesen't return the intersecting area. It returns the whole 
> >> polygons, that partly intersect the parcel. So I could add an additional 
> >> intersection():
> >> 
> >> coalesce( 
> >>   array_sum( 
> >> overlay_intersects(
> >>   layer:= 'forest', 
> >>   expression:= area(
> >> intersection(
> >>   @geometry, geometry(get_feature_by_id()
> >> )
> >>   )
> >> )
> >>   )
> >> , 0)
> >> 
> >> @geometry is calculated in the context of the layer forests. How could I 
> >> access the geometry of the parcel inside of overlay_intersects()? 
> >> get_feature_by_id() doesn't seem to help, since I don't see a way to get 
> >> the actual ID of the parcel. 
> >> It is not possible to return @geometry as expression in overlay_intersects 
> >> and do the intersection outside.
> >> 
> >> Does any one have an idea, how I could get the intersected area?
> >> Thank you. Bruno
___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


[Qgis-user] Calculate intersecting area of two layers in a virtual field. Context of @geometry in overlay_intersects()

2024-04-04 Thread Bruno Streit via QGIS-User
Dear list

Great, how powerful expressions are in QGIS!
I have two polygon layers, one with parcels and one with forests. In a virtual 
field of the layer parcels I'm trying to calculate the area covered with 
forest. I can sum the area of intersecting forests in a virtual field with the 
follwing expression:

coalesce( 
  array_sum( 
overlay_intersects(
  layer:= 'forest', 
  expression:= area(@geometry)
)
  )
, 0)

But @geometry doesen't return the intersecting area. It returns the whole 
polygons, that partly intersect the parcel. So I could add an additional 
intersection():

coalesce( 
  array_sum( 
overlay_intersects(
  layer:= 'forest', 
  expression:= area(
intersection(
  @geometry, geometry(get_feature_by_id()
)
  )
)
  )
, 0)

@geometry is calculated in the context of the layer forests. How could I access 
the geometry of the parcel inside of overlay_intersects()? get_feature_by_id() 
doesn't seem to help, since I don't see a way to get the actual ID of the 
parcel. 
It is not possible to return @geometry as expression in overlay_intersects and 
do the intersection outside.

Does any one have an idea, how I could get the intersected area?
Thank you. Bruno
___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


[Qgis-user] Couldn't load plugin XY due to an error when calling its classFactory() method

2023-03-23 Thread Bruno Streit via QGIS-User
Hi List
 
I keep getting an error when loading or installing plugins as 'Geometry 
Paster', 'Geodata to ENVI-met' and many others. It seems not to be a plugin 
related error, since it happens with many plugins. Or is it?
 
I'm working with QGIS Firenze ltr and had the problem with Biatowieza before. 
The plugins where updated in this year and are not outdated. In the web I find 
old error reports but the solutions seem not to fit. It seems to have to do 
with a 'locale' Setting:
locale = QSettings().value('locale/userLocale')[0:2]
TypeError: 'NoneType' object is not subscriptable
 
Any hints, how I could solve this?
 
Thank you.
Bruno
 
The whole report:
 
Couldn't load plugin 'geodata2envimet' due to an error when calling its 
classFactory() method
 


TypeError: 'NoneType' object is not subscriptable


Traceback (most recent call last):
  File "C:\PROGRA~1/QGIS32~1.4/apps/qgis-ltr/./python\qgis\utils.py", line 423, 
in _startPlugin
plugins[packageName] = package.classFactory(iface)
  File 
"C:\Users/icuser/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\geodata2envimet\__init__.py",
 line 36, in classFactory
return Geo2ENVImet(iface)
  File 
"C:\Users/icuser/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\geodata2envimet\geodata2ENVImet.py",
 line 2553, in __init__
locale = QSettings().value('locale/userLocale')[0:2]
TypeError: 'NoneType' object is not subscriptable



Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 
64 bit (AMD64)]
QGIS version: 3.28.4-Firenze Firenze, fd0fb72ab3
 


Python Path:


* C:/PROGRA~1/QGIS32~1.4/apps/qgis-ltr/./python
* C:/Users/icuser/AppData/Roaming/QGIS/QGIS3\profiles\default/python
* C:/Users/icuser/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
* C:/PROGRA~1/QGIS32~1.4/apps/qgis-ltr/./python/plugins
* C:\Program Files\QGIS 3.28.4\bin\python39.zip
* C:\PROGRA~1\QGIS32~1.4\apps\Python39\DLLs
* C:\PROGRA~1\QGIS32~1.4\apps\Python39\lib
* C:\Program Files\QGIS 3.28.4\bin
* C:\Users\icuser\AppData\Roaming\Python\Python39\site-packages
* C:\PROGRA~1\QGIS32~1.4\apps\Python39
* C:\PROGRA~1\QGIS32~1.4\apps\Python39\lib\site-packages
* C:\PROGRA~1\QGIS32~1.4\apps\Python39\lib\site-packages\win32
* C:\PROGRA~1\QGIS32~1.4\apps\Python39\lib\site-packages\win32\lib
* C:\PROGRA~1\QGIS32~1.4\apps\Python39\lib\site-packages\Pythonwin
* C:/Users/icuser/AppData/Roaming/QGIS/QGIS3\profiles\default/python
* C:/data/Solothurn_Mikroklima


 
 ___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user