From: sfeam <sf...@us...> - 2017-09-01 06:28:12
|
On Thursday, 31 August 2017 22:44:01 Dima Kogan wrote: > Hi. I just stumbled on another bug with rgbimages. If somebody knows > what's causing it, that'd be appreciated. This is a very complicated one. I'll look at it in more detail over the weekend. For now I'll just note: - The script basically does not work with 5.2 or current cvs, so I assume you are using 5.0? - To make the script work with 5.2 I can move the range outside the plot command: set xrange [-120:-80] set yrange [20:60] plot "montage_40_-99_1300miles_4.png" binary filetype=png flipy ... - At that point I see (I think) the same thing you do in that the single explicit point lies North of rather than exactly on top of the Los Angeles marker. - I'm not sure whether or not I see the same thing as you on zooming. At first glance it looks to me that the zoomed-in placement is correct (point is on top of LA) in the zoom view even though it was not in the original full view. The closer in I zoom the closer to perfect the superposition becomes. Is that what you see or do you see something else? - So I guess my question is, would it be a correct description to say that the plot is correct but only after a zoom operation? If so, that sounds easier to track down than "it's always wrong". - One possible problem occurs to me. The coordinates mapped to an image pixel describe the center of the pixel, not a corner. You may have constructed your mapping with that in mind, or maybe not. If not then perhaps adjusting the mapping function will fix everything. Ethan > 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? |