I need to create a script, probably JS or Python, to perform the following:
I have a polygonal region -- no "holes", and always fully convex -- for which I need to extract the pixel data from one of a set of map layers. Each of the layers in question will consist of either (a) standard quadtree-based map tiles, or (b) a set of non-overlapping rectangular GeoTIFF files (or JPEG/PNG files with lat/lon for the four corners).
So, the intended input of this script/function/method will be a polygon (specified in lat/lon coordinates), and a map layer. The output will be a rectangular png image (or some matrix representation of pixels that'll be used to generate a png), where all pixels that either fall outside the polygon or don't have any images in the map layer that overlap them will be transparent, and the rest will contain the pixel value taken from the map layer.
This feels like something someone's probably done before, but I'm not finding any modules that do it.
Does anyone know if one exists?