Vector to Raster Conversion

Vector to raster conversion in Earth Engine is handled by the featureCollection.reduceToImage() method. This method assigns pixels under each feature the value of the specified property. This example uses the counties data to create an image representing the population of each county:

// Load a collection of US counties with census data properties.
var counties = ee.FeatureCollection('ft:1S4EB6319wWW2sWQDPhDvmSBIVrD3iEmCLYB7nMM');

// Make an image out of the population attribute and display it.
var popImage = counties
  .filter(ee.Filter.neq('Census 2000 Population', null))
  .reduceToImage({
    properties: ['Census 2000 Population'],
    reducer: ee.Reducer.first()
});
Map.setCenter(-99.976, 40.38, 5);
Map.addLayer(popImage, {min: 0, max: 1000000, palette: ['0000FF', '00FF00', '00FFFF', 'FF0000']});
    

If the features overlap, specify a reducer to indicate how to aggregate properties of overlapping features. In the previous example, since there is no overlap, an ee.Reducer.first() is sufficient. As in this example, pre-filter the data to eliminate nulls that can not be turned into an image. The output should look something like Figure 1, which illustrates the distribution of population by county in the US.

reduceToImage output
Figure 1. The result of reduceToImage() using the ‘Census 2000 Population’ property of the US counties FeatureCollection.

Send feedback about...

Google Earth Engine API