consbio / ncdjango

A NetCDF mapserver app for Django.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Conditionally return JPEG, if possible

brendan-ward opened this issue · comments

Basic tests of regions fully covered by data pixels (no NODATA) result in JPGs that are somewhat to quite a bit smaller than the default PNG24, with no noticeable encoding artifacts.

This only works if there are no NODATA pixels within the warped area. While this is easy in numpy arrays, this may be harder to determine efficiently for images. If you have an alpha channel, it could be possible to look for values in there that indicate NODATA.

I think if we do this, we should present this as an extra option in the ArcGIS (Extended) API (the interface that supports extra functionality like styling). Otherwise, it feels like bad form to return JPEG images to a client that specifically requested another format.

What's the decrease compared PNG8?

Don't know, since that type wasn't supported when I did my tests. Well worth testing. For an arbitrary area that included about 20 data pixels on edge prior to reprojection, and across a fairly large range in values, I saw an output file size of 1/3 the size compared to PNG (24?) for the same footprint.

Good point about extended API instead of core API. Maybe an additional format type in addition to the standard ones? E.g., smallest instead of png8? Or were you thinking a new query parameter?

Testing in clover w/ PNG8 produces a PNG smaller than JPG at default quality (42% of size of JPG). So PNG8 is likely to be better than JPG in this case.

And in this specific case, PNG24 was smaller too, by just a little.

I'm actually now rethinking this request, seeing how it works out on some test map data. Compared to PNG8s, file sizes are larger in JPG, and there are quite noticeable artifacts. Let's stick to higher quality formats for now, except when JPG is actually requested.

Would require some tuning to get the most of out JPG in this usage.