plotting a contour map from CSV file

Hello Jeff,

>> - Points stored in the above descripbed format (lat, lon, value)?

This one I solved using a m.scatter() function

>> - Interpolate a grid of data points by using different interpolation

methods like inverse distance wheighting, natural neighbor

interpolation, etc. to get a contour map?

> For interpolation of irregular, randomly distributed data points see
> http://www.scipy.org/Cookbook/Matplotlib/

Gridding_irregularly_spaced_data.

>
> However, if there is some structure to the data grid then it's probably
> better not to use these approaches.

The problem is that although regular spaced the grid is still to large to
countour to a nice map. I will play a bit more with contour and other
interpolation functions.

I tried griddata:

2) using the griddata package
Here I was nearly without orientation how to call griddata correctly.

I tried again.

Here is what I got:
    x = data[:,1]
    y = data[:,0]
    z = data[:,2]
    X, Y = mlab.meshgrid(x, y)
    X, Z = mlab.meshgrid(x, y)
    # zi = griddata(x,y,z,xi,yi,**kwargs)
    Z = grid.griddata(x,y,z, X, Y)
  plt.contour(X,Y, Z)
  
=> ValueError: output grid defined by xi,yi must be monotone increasing

The coordinates are stored in a way that first longitude (x) increases and
then the latitude (y) increases.
10 6.0 4
10 6.25 3
10 6.50 2
10 6.75 1
10 6.0 6
11 6.25 7
11 6.50 6
11 6.75 9
12 6.0 4

What how do I need to arrange my data to get it monotone increasing for
griddata?

Thanks for your help. One settled I will send you another example for the
examples package.

Kind regards,
Timmie

Tim Michelsen wrote:

Hello Jeff,

- Points stored in the above descripbed format (lat, lon, value)?
        

This one I solved using a m.scatter() function

  - Interpolate a grid of data points by using different interpolation
methods like inverse distance wheighting, natural neighbor
        

interpolation, etc. to get a contour map?
  

For interpolation of irregular, randomly distributed data points see
http://www.scipy.org/Cookbook/Matplotlib/
      

Gridding_irregularly_spaced_data.
  

However, if there is some structure to the data grid then it's probably
better not to use these approaches.
      

The problem is that although regular spaced the grid is still to large to
countour to a nice map. I will play a bit more with contour and other
interpolation functions.

I tried griddata:

2) using the griddata package
Here I was nearly without orientation how to call griddata correctly.
    

I tried again.

Here is what I got:
    x = data[:,1]
    y = data[:,0]
    z = data[:,2]
    X, Y = mlab.meshgrid(x, y)
    X, Z = mlab.meshgrid(x, y)
    # zi = griddata(x,y,z,xi,yi,**kwargs)
    Z = grid.griddata(x,y,z, X, Y)
  plt.contour(X,Y, Z)
  
=> ValueError: output grid defined by xi,yi must be monotone increasing

The coordinates are stored in a way that first longitude (x) increases and
then the latitude (y) increases.
10 6.0 4
10 6.25 3
10 6.50 2
10 6.75 1
10 6.0 6
11 6.25 7
11 6.50 6
11 6.75 9
12 6.0 4

What how do I need to arrange my data to get it monotone increasing for
griddata?

Thanks for your help. One settled I will send you another example for the
examples package.
Kind regards,
Timmie

Timmie: You shouldn't use griddata. You have a regular lat/lon grid, so it's just a matter of loading the data into the proper 2-d array. Please send a self-contained script (and post the data somewhere) and then we can help you.

-Jeff

ยทยทยท

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328