I have a bunch of points representing bird observations, and I need to convert this to an image in GEE where each pixel value is the total number of observations in each 1 km pixel. This is a very common task with ecological data, and in ArcGIS I would use Point to Raster. But I can't figure out what the equivalent would be in GEE.
As an example, here are some points and a bounding polygon:
var points = ee.Feature(ee.Geometry.MultiPoint(
[[57.43610672115551, -20.298790475544028],
[57.566569367639886, -20.221490947834383],
[57.695658723108636, -20.319397176387103],
[57.676432648889886, -20.171225637115814],
[57.58991531490551, -20.216336278108052],
[57.57892898678051, -20.225356838032646],
[57.572062531702386, -20.227934044777072]]),{});
var poly =
ee.Feature(
ee.Geometry.Polygon(
[[[57.36469558834301, -20.087414125113316],
[57.36469558834301, -20.499588506612334],
[57.85908035396801, -20.499588506612334],
[57.85908035396801, -20.087414125113316]]], null, false), {});
So the resulting image should have the extent of poly
, a scale of 1 km, and pixel values corresponding to the number of points in each pixel. I thought reduceToImage
would do this, but that seems to be more for summarising properties of polygon geometries.
Best Answer
The
reduceToImage
function only converts a featureCollection to an Image with unknown spatial information (no scale or projection) based on a property you select. You will have take the undefined Image and perform some operations to get point count per pixel. You do this by projecting the converted image and then reducing the image scale to desired resolution with a reprojection, however, there are some fun EE quirks withreduceResolution
along the way. Here is an example:Here is a working link. I hope this help!