title: Using a vector layer as an input to a raster source in openlayers
body: <p>I'm trying to use vector features as a mask for a raster source in Openlayers 5. (I want to do calculations on raster data only within specific jurisdictions, which are dynamically selectable by the user.) To do this, I tried to use the vector layer with my features as an input to the raster source, and then test each pixel to see if the mask is present.</p>
  
  <p>The <a href="https://openlayers.org/en/latest/apidoc/module-ol_source_Raster.html" rel="nofollow noreferrer">documentation</a> indicates that this should be possible if the vector layer is configured with the option <code>renderMode: 'image'</code>. However, when the raster layer attempts to run I get a <code>TypeError: h.getImage is not a function</code>.</p>
  
  <p>My code is as follows:</p>
  
  <pre class="lang-js prettyprint-override"><code>// The base raster data
  var arc = new TileArcGISRest({
      params: {
          'LAYERS': "view:0"
      },
      url: myDataURL,
      crossOrigin: 'anonymous',
  });
  
  // The vector mask in GeoJSON format
  var town_vector = new ol.source.Vector({
      url: 'towns.json',
      format: new ol.format.GeoJSON(),
  });
  
  // The layer based on that vector
  var town_layer = new ol.layer.Vector({
      title: 'added Layer',
      source: town_vector,
      renderMode: 'image',
      style: interest_style,
  });
  
  // The raster source that attempts the analysis
  var summary_raster = new RasterSource({
      sources: [arc, town_layer],
      operation: function (pixels, data) {
          var pixel = pixels[0];
          var mask_pixel = pixels[1];
          if (mask_pixel[0] == mask_value) {
              run_calculation(pixel)
          }
      },
      lib: {
          run_calculation: run_calculation,
      }
  });
  </code></pre>
  
  <p>It works perfectly when I remove the "town_layer" from the source, and eliminate the masking logic. However, when I add the "town_layer" to the raster source I get the aforementioned <code>TypeError: h.getImage is not a function</code>. How can I "rasterize" this vector layer and use it as in input to the raster source?</p>