## matplotlib-users

 [Matplotlib-users] Re: drawing the GPS data on the map From: Petr Jakes - 2005-09-22 11:04:50 ```Jeff, thanks a lot for giving me your advices. Please understand it is about 20 years I am from the university so it is not always easy to get things about maps etc. back to my head :) I did study your some example code http://matplotlib.sourceforge.net/screenshots/plotmap.py and I thing I am able to follow it and understand how you are using it. Generally it looks for me like you: a) read the pre-prepared (sorted) scalar field (latitudes, longitudes, values) b) store it in the three numarrays (topoin, lons , lats) c) transform coordinates (lons , lats) to the chosen projection (to the native map projection grid) + interpolate data values (topoin) to the transformed coordinates. d) assign color to the interpolated "data values" using colorpalet from the 'imshow' e) plot "new" transformed "color" scalar field over the map (please correct me, if I am wrong). Now I am reading your first posting again: ---snip--- > However, you may be able to do it by importing your image using PIL, > converting it to a Numeric array and then plotting it over the map > projection using imshow. To see how to convert an image to and from > a Numeric array see http://effbot.org/zone/pil-numpy.htm ---Snip--- I am trying to think how to convert image (scanned map) to the Numeric array. My map is in Transverse Mercator projection (this is my intended target projection as well) and it has WGS84 coordinates (datum) on it. I just can't figure out, how I can identify the exact pixel, where (at least) the 3 wgs84 coordinates intersection point are located. I think I need such a identification so I will be able to assign the information about position (coordinates) to each image pixel during the conversion of the image to the Numeric array? Maybe there is some general function how to "calibrate" the picture(pixels) to the coordinates. Any idea about it? Or is my approach completely wrong? Thks and regards Petr ```
 [Matplotlib-users] Re: drawing the GPS data on the map From: Petr Jakes - 2005-09-23 19:23:23 ```Jeff, sorry I am bothering you with my postings :) Maybe I am missing something, but your way looks too complicated to me.... below code works for me. BUT!!!: I just wonder, why meridians are not plotted symmetrically to the vertical axis. Because of that it will be a little bit more difficult to adjust (calibrate) my map (picture) properly. Try to run the code without an image (as it is) and you will see it. Anyway, if you think the following code is fundamentally correct, I can post my experiences how to scan the paper map and how to "calibrate" scanned picture, so it can be shown with the Basemap coordinates properly. Petr ======================================= from matplotlib.toolkits.basemap import Basemap from pylab import * m = Basemap(llcrnrlon=14.,llcrnrlat=50,urcrnrlon=16.,urcrnrlat=51.,\ resolution='c',area_thresh=10.,projection='tmerc',\ lat_0=50.,lon_0=15.) ##import Image ##ima=Image.open('/root/Desktop/native_nslu2/sejmout0006.jpg') ##ima1=ima.transform((1545,1730),Image.QUAD, (0,209,0,1940,1535,1938,1530,207)) ##im = m.imshow(ima1) # draw parallels delat = 0.2 circles = arange(50.,51.,delat) m.drawparallels(circles,labels=[1,0,0,0],fontsize=10) # draw meridians delon = 0.25 meridians = arange(14,16,delon) m.drawmeridians(meridians,labels=[0,0,1,0],fontsize=10) title('Transverse Mercator Projection') # print 'plotting Transverse Mercator example, close plot window to proceed ...' show() ```
 Re: [Matplotlib-users] Re: drawing the GPS data on the map From: Jeff Whitaker - 2005-09-23 19:35:57 ```Petr Jakes wrote: >below code works for me. BUT!!!: I just wonder, why meridians are not >plotted symmetrically to the vertical axis. Because of that it will be >a little bit more difficult to adjust (calibrate) my map (picture) >properly. Try to run the code without an image (as it is) and >you will see it. > > Petr: I don't see the problem. Do you expect the meridians to be vertical lines? They won't be for a transverse mercator projection - they would be for a regular mercator projection. What map projection does you scanned map use? BTW: every time I reply to you your email bounces. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/CDC R/CDC1 Email : Jeffrey.S.Whitaker@... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg ```
 [Matplotlib-users] Re: drawing the GPS data on the map From: Petr - 2005-09-23 20:44:38 Attachments: image.png ```JW> Petr Jakes wrote: >>below code works for me. BUT!!!: I just wonder, why meridians are not >>plotted symmetrically to the vertical axis. Because of that it will be >>a little bit more difficult to adjust (calibrate) my map (picture) >>properly. Try to run the code without an image (as it is) and >>you will see it. >> >> JW> Petr: JW> I don't see the problem. Do you expect the meridians to be vertical JW> lines? They won't be for a transverse mercator projection - they would JW> be for a regular mercator projection. What map projection does you JW> scanned map use? JW> BTW: every time I reply to you your email bounces. JW> -Jeff Jeff, IMHO 15th meridian has to be (according to the Basemap settings in the code) parallel to the vertical sides of the picture (it is!) and the direction to the left side and to the right side has to be the same (it is not)! So the picture is not! vertically symmetric (it is obvious if you check the top right and the top left corner of the picture in the attachment for example). There you can see the left most meridian (14) starts in the bottom left corner and goes up (slightly right). So I expect the right most meridian (16) to start in the bottom right corner and go up (slightly left). But.... :) My map uses Transverse Mercator projection, the Lat. of origin is 50N and the Long. of origin is 15E. Petr PS: this is the first time I have got reply from you directly to my mail box as well. Nothing wrong with our mail server for a long time :) Maybe some Internet mystery :))))) Or just wrong 'reply to' address.....```
 [Matplotlib-users] Re: drawing the GPS data on the map From: Jeff Whitaker - 2005-09-23 21:15:05 ```Petr wrote: > >JW> Petr: > >JW> I don't see the problem. Do you expect the meridians to be vertical >JW> lines? They won't be for a transverse mercator projection - they would >JW> be for a regular mercator projection. What map projection does you >JW> scanned map use? > >JW> BTW: every time I reply to you your email bounces. > >JW> -Jeff > >Jeff, > >IMHO 15th meridian has to be (according to the Basemap settings in the >code) parallel to the vertical sides of the picture (it is!) > OK, I follow you so far. >and the >direction to the left side and to the right side has to be the same >(it is not)! > > now you lost me. >So the picture is not! vertically symmetric (it is obvious if you >check the top right and the top left corner of the picture in the >attachment for example). There you can see the left most meridian (14) >starts in the bottom left corner and goes up (slightly right). So I >expect the right most meridian (16) to start in the bottom right >corner and go up (slightly left). But.... :) > > The top right corner of the map is 16 degrees east - so the meridian starts there and then goes slightly east and off the map. That's why you don't see it. The 14 degree meridian starts at the lower left corner and bends slight east into the map region - so you can actually see it on the map. I see nothing wrong. You probably want the lower right corner to be at 16 degrees, not the upper right. >My map uses Transverse Mercator projection, the Lat. of origin is 50N >and the Long. of origin is 15E. > > OK. You've defined the projection correctly then, but what do you want the lower left and upper right corners of the map to be? -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/CDC R/CDC1 Email : Jeffrey.S.Whitaker@... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg ```
 [Matplotlib-users] Re[2]: drawing the GPS data on the map From: Petr - 2005-09-23 21:38:55 ```---SNIP--- JW> I see nothing wrong. You probably want the lower right JW> corner to be at 16 degrees, not the upper right. Yes exactly, I would like to have the lower right corner to be at 16 degrees. I can see the intersection points of parallel 50 with the meridians 14 and 16 and of the parallel 51 with the meridian 15 on the scanned image of the map. Than I can (using some graphic editing software, GIMP for example) find (determine) which pixels are representing these int. points and cut the needed rectangle off the image (from the GIMP, or directly in the code using the image "transform" method). This is the way how to calibrate the picture (or how to set up the same rectangle area on the picture and on the Basemap projection). Petr >>My map uses Transverse Mercator projection, the Lat. of origin is 50N >>and the Long. of origin is 15E. >> >> JW> OK. You've defined the projection correctly then, but what do you want JW> the lower left and upper right corners of the map to be? JW> -Jeff ```
 Re: [Matplotlib-users] Re: drawing the GPS data on the map From: Jeff Whitaker - 2005-09-22 12:51:48 ```Petr Jakes wrote: >I am trying to think how to convert image (scanned map) to the Numeric array. >My map is in Transverse Mercator projection (this is my intended >target projection as well) and it has WGS84 coordinates (datum) on it. > >I just can't figure out, how I can identify the exact pixel, where (at >least) the 3 wgs84 coordinates intersection point are located. I think >I need such a identification so I will be able to assign the >information about position (coordinates) to each image pixel during >the conversion of the image to the Numeric array? Maybe there is some >general function how to "calibrate" the picture(pixels) to the coordinates. > >Any idea about it? Or is my approach completely wrong? > >Thks and regards > >Petr > > > Petr: I think the best approach would be make your scanned map into a 'georeferenced' image (such as a geotiff). I think you can do this with gdal (http://gdal.maptools.org). Once the image is georeferenced, I can give you an example showing how to read it in using the python gdal module, convert it to an array and plot it with basemap. Sorry I can't be of more help, but this is really outside my realm of expertise. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/CDC1 FAX : (303)497-6449 325 Broadway Web : http://www.cdc.noaa.gov/~jsw Boulder, CO, USA 80305-3328 Office: Skaggs Research Cntr 1D-124 ```