I want to find out the timezone a GPX track is in by looking up the first coordinate pair. I took the shapefile from Timezone Boundary Builder and created a PNG image via qgis from it (using the default projection, "WGS 84 – EPSG:4326"), with one color per defined timezone. I also have a color-timezone mapping.
I know the width and the height of the image (which represents all possible coordinates on earth), and I have a lat/lon pair. Now I "only" need to map the coordinate pair to the respective pixel (x/y) to get it's color, which then maps to the timezone I need.
But how do I calculate the mapping? I know how to do it using the Mercator projection (I wrote a function doing that some time ago: mercatorProjection, but I'm struggling to find respective code for EPSG:4326 (or WGS84).
y=90
, bottom hasy=-90
, left side hasx=-180
, right side hasx=180
. Conversion to image pixels is then just linear function, taking into account image size in pixels.