daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Jan 18th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from qgis.core import *
  2. from qgis.gui import *
  3. from qgis.utils import iface
  4.  
  5. @qgsfunction(args="auto", group='Custom')
  6. def getAttribudeIntersectAtlasFeature(intersectLayername, intersectFieldname, geomAtlas, feature, parent):
  7.     # If geomAtlas is empty, return empty string
  8.     if (geomAtlas is None):
  9.         return ''
  10.  
  11.     # Get layer reference from layername
  12.     intersectLayer = QgsMapLayerRegistry.instance().mapLayersByName(intersectLayername)[0]
  13.  
  14.     # Raise if layer not found
  15.     if intersectLayer is None:
  16.         raise Exception("Layer not found: " + intersectLayername)
  17.  
  18.     # Count point within current Atlas feature
  19.     countryname = ''
  20.     for ft in intersectLayer.getFeatures():
  21.         intersectGeom = ft.geometry()
  22.         if (intersectGeom is None):
  23.             continue
  24.         if intersectGeom.intersects(geomAtlas):
  25.             countryname += ft[intersectFieldname] + ','
  26.  
  27.     return countryname[:-1]
  28.    
  29. [% getAttribudeIntersectAtlasFeature( 'world', 'country',  $atlasgeometry )%]
  30.    
  31. [% aggregate('LAYER_NAME','concatenate',"ATTRIBUTE",
  32.               within($geometry,@atlas_geometry), ',') %]
  33.    
  34. array_to_string(
  35.     array_slice(
  36.         string_to_array(
  37.             aggregate('LAYER','concatenate',"ATTRIBUTE",
  38.                       within($geometry,@atlas_geometry),',')
  39.          ,',')
  40.      ,0,19)
  41. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top