From: Dima K. <gn...@di...> - 2017-09-01 05:44:16
|
Hi. I just stumbled on another bug with rgbimages. If somebody knows what's causing it, that'd be appreciated. I'm plotting an image showing a map composed of stitched openstreetmap tiles (attached). The mapping between pixels in this image and lat/lon is linear in longitude and nonlinear in latitude. I'm plotting the image pixels onto x2y2, and using linked axes to get the latitude on y and longitude on x. The script is this: set x2tics auto set y2tics auto lon0 = -123.5614 lon_offset = 180.0 + lon0 zoom = 4. px_to_lon(x) = x/(256. * 2.**4)*360. - 180. + lon_offset lon_to_px(x) = (x-lon_offset+180.)/360. * 2.**zoom * 256. lat_offset_px = 1215.969 s1_cos(x) = (sin(x)+1)/cos(x) inv_s1_cos(x) = asin( (x**2 - 1)/(x**2 + 1) ) px_to_lat(x) = inv_s1_cos(exp((1 - (x + lat_offset_px)/(2.**zoom * 256) *2)*pi))*180./pi lat_to_px(x) = (1 - log( (sin(x*pi/180) + 1.)/cos(x*pi/180) )/pi)/2. * 2.**zoom * 256 - lat_offset_px set link x2 via lon_to_px(x) inverse px_to_lon(x) set link y2 via lat_to_px(y) inverse px_to_lat(y) plot [x=-120:-80][y=20:60] "montage_40_-99_1300miles_4.png" binary filetype=png flipy with rgbimage notitle axis x2y2, '-' with points axis x2y2 60 419 e Note that the circle representing Los Angeles lies at pixel coordinates 60,419 and I'm plotting a point there. The corresponding latlon is roughly -118,34. The pixels are on x2y2 and the point is on x2y2, so this point should be rendered in that circle. I'm not seeing that at all, however. The point is at y2=419 as it should be, but the Los Angeles circle is roughly at y2=448. The x coordinates match properly. Furthermore, zooming in makes it clear that gnuplot is confused: interactively zooming on the plotted point shows me the zoomed LA circle, even though visually the LA circle was elsewhere. Any pointers? |