Skip to main content
100%

Reprojected Raster Clipping

✓ Published0🌍 Public
Aandrew-reid
Last edited Mar 17, 2017
Created on Jan 25, 2017

This example shows a reprojected raster of the Blue Marble satellite image, clipped to a Hammer projection of the Earth. The code loads the equirectangular source image onto a Canvas and uses `d3.geo.projection` with the Hammer raw function to invert each target pixel’s coordinates, then checks the forward projection to verify pixel validity. It manually reads pixel data via Canvas `getImageData` and writes to a new `createImageData` buffer, skipping out-of-bounds or non-invertible locations. The result renders a smoothly clipped, non-circular projected map using d3.v3 and Canvas 2D drawing.

AI-generated description

This bl.ock takes an alternative approach to this one, in that it is not dependent on a circular projection disc.

It runs each pixel through a forward then inverse projection to see if the pixel should be plotted. It is in response to a SO question, [this was a potential answer] (http://stackoverflow.com/a/41856996/7106086). This is required in transforming the equiratangular source image as the d3 projection function is not one to one.

Similar vizzes