Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
removing contour lines outside map

Subject: removing contour lines outside map

From: Poulomi

Date: 6 Oct, 2013 13:51:09

Message: 1 of 6

Hi,

I have 1000 station data points across US, for which I have precipitation data. I need to plot contour map of precipitation distribution across US from these 1000 station data. I used foll. code for that:

[LatGrid, LonGrid] = meshgrid(linspace(min(Lat_US), max(Lat_US)), ...
                        linspace(min(Lon_US), max(Lon_US)));

Severity_grid = griddata(Lat_US, Lon_US, Srty_10yr_US, LatGrid, LonGrid);
contourm(LatGrid, LonGrid, Severity_grid);colorbar;

but few contour lines are falling outside CONUS map; can anybody kindly let me know how to remove these contour lines outside US map. Thanks in advance...

Subject: removing contour lines outside map

From: TideMan

Date: 6 Oct, 2013 19:12:13

Message: 2 of 6

On Monday, October 7, 2013 2:51:09 AM UTC+13, Poulomi wrote:
> Hi,
>
>
>
> I have 1000 station data points across US, for which I have precipitation data. I need to plot contour map of precipitation distribution across US from these 1000 station data. I used foll. code for that:
>
>
>
> [LatGrid, LonGrid] = meshgrid(linspace(min(Lat_US), max(Lat_US)), ...
>
> linspace(min(Lon_US), max(Lon_US)));
>
>
>
> Severity_grid = griddata(Lat_US, Lon_US, Srty_10yr_US, LatGrid, LonGrid);
>
> contourm(LatGrid, LonGrid, Severity_grid);colorbar;
>
>
>
> but few contour lines are falling outside CONUS map; can anybody kindly let me know how to remove these contour lines outside US map. Thanks in advance...

Set the nodes outside your area of interest to NaN.

Subject: removing contour lines outside map

From: Poulomi

Date: 1 Jan, 2014 19:31:07

Message: 3 of 6

TideMan <mulgor@gmail.com> wrote in message <51eed7b0-594c-4f24-b07b-1614011a9a95@googlegroups.com>...
> On Monday, October 7, 2013 2:51:09 AM UTC+13, Poulomi wrote:
> > Hi,
> >
> >
> >
> > I have 1000 station data points across US, for which I have precipitation data. I need to plot contour map of precipitation distribution across US from these 1000 station data. I used foll. code for that:
> >
> >
> >
> > [LatGrid, LonGrid] = meshgrid(linspace(min(Lat_US), max(Lat_US)), ...
> >
> > linspace(min(Lon_US), max(Lon_US)));
> >
> >
> >
> > Severity_grid = griddata(Lat_US, Lon_US, Srty_10yr_US, LatGrid, LonGrid);
> >
> > contourm(LatGrid, LonGrid, Severity_grid);colorbar;
> >
> >
> >
> > but few contour lines are falling outside CONUS map; can anybody kindly let me know how to remove these contour lines outside US map. Thanks in advance...
>
> Set the nodes outside your area of interest to NaN.
Thanks, but I am using griddata, which is interpolating the data points, how I can identify which of the co-ordinates are falling outside US domain. Kindly let me know some sample example, will be useful. Thanks

Subject: removing contour lines outside map

From: Rob Comer

Date: 2 Jan, 2014 12:31:07

Message: 4 of 6

TideMan is right. Just add something like this to insert NaNs before calling contourm.

load('conus','uslat','uslon')
outsideUS = ~inpolygon(LonGrid,LatGrid,uslon,uslat);
Severity_grid(outsideUS) = NaN;

I also recommend that you use clabelm instead of colorbar. (You'll need the optional c, h outputs from contourm to do that.)


"Poulomi" wrote in message <la1qdr$luj$1@newscl01ah.mathworks.com>...
> TideMan <mulgor@gmail.com> wrote in message <51eed7b0-594c-4f24-b07b-1614011a9a95@googlegroups.com>...
> > On Monday, October 7, 2013 2:51:09 AM UTC+13, Poulomi wrote:
> > > Hi,
> > >
> > >
> > >
> > > I have 1000 station data points across US, for which I have precipitation data. I need to plot contour map of precipitation distribution across US from these 1000 station data. I used foll. code for that:
> > >
> > >
> > >
> > > [LatGrid, LonGrid] = meshgrid(linspace(min(Lat_US), max(Lat_US)), ...
> > >
> > > linspace(min(Lon_US), max(Lon_US)));
> > >
> > >
> > >
> > > Severity_grid = griddata(Lat_US, Lon_US, Srty_10yr_US, LatGrid, LonGrid);
> > >
> > > contourm(LatGrid, LonGrid, Severity_grid);colorbar;
> > >
> > >
> > >
> > > but few contour lines are falling outside CONUS map; can anybody kindly let me know how to remove these contour lines outside US map. Thanks in advance...
> >
> > Set the nodes outside your area of interest to NaN.
> Thanks, but I am using griddata, which is interpolating the data points, how I can identify which of the co-ordinates are falling outside US domain. Kindly let me know some sample example, will be useful. Thanks

Subject: removing contour lines outside map

From: Rob Comer

Date: 2 Jan, 2014 12:51:07

Message: 5 of 6

Oops, I meant to say clegendm instead of clabelm. But I think either one would be more useful than colorbar.

"Rob Comer" <rob.comer.nospam@mathworks.com> wrote in message <la3m6b$kdo$1@newscl01ah.mathworks.com>...
> TideMan is right. Just add something like this to insert NaNs before calling contourm.
>
> load('conus','uslat','uslon')
> outsideUS = ~inpolygon(LonGrid,LatGrid,uslon,uslat);
> Severity_grid(outsideUS) = NaN;
>
> I also recommend that you use clabelm instead of colorbar. (You'll need the optional c, h outputs from contourm to do that.)
>
>
> "Poulomi" wrote in message <la1qdr$luj$1@newscl01ah.mathworks.com>...
> > TideMan <mulgor@gmail.com> wrote in message <51eed7b0-594c-4f24-b07b-1614011a9a95@googlegroups.com>...
> > > On Monday, October 7, 2013 2:51:09 AM UTC+13, Poulomi wrote:
> > > > Hi,
> > > >
> > > >
> > > >
> > > > I have 1000 station data points across US, for which I have precipitation data. I need to plot contour map of precipitation distribution across US from these 1000 station data. I used foll. code for that:
> > > >
> > > >
> > > >
> > > > [LatGrid, LonGrid] = meshgrid(linspace(min(Lat_US), max(Lat_US)), ...
> > > >
> > > > linspace(min(Lon_US), max(Lon_US)));
> > > >
> > > >
> > > >
> > > > Severity_grid = griddata(Lat_US, Lon_US, Srty_10yr_US, LatGrid, LonGrid);
> > > >
> > > > contourm(LatGrid, LonGrid, Severity_grid);colorbar;
> > > >
> > > >
> > > >
> > > > but few contour lines are falling outside CONUS map; can anybody kindly let me know how to remove these contour lines outside US map. Thanks in advance...
> > >
> > > Set the nodes outside your area of interest to NaN.
> > Thanks, but I am using griddata, which is interpolating the data points, how I can identify which of the co-ordinates are falling outside US domain. Kindly let me know some sample example, will be useful. Thanks

Subject: removing contour lines outside map

From: Poulomi

Date: 2 Feb, 2014 19:49:08

Message: 6 of 6

"Rob Comer" <rob.comer.nospam@mathworks.com> wrote in message <la3m6b$kdo$1@newscl01ah.mathworks.com>...
> TideMan is right. Just add something like this to insert NaNs before calling contourm.
>
> load('conus','uslat','uslon')
> outsideUS = ~inpolygon(LonGrid,LatGrid,uslon,uslat);
> Severity_grid(outsideUS) = NaN;
>
> I also recommend that you use clabelm instead of colorbar. (You'll need the optional c, h outputs from contourm to do that.)
>
>
> "Poulomi" wrote in message <la1qdr$luj$1@newscl01ah.mathworks.com>...
> > TideMan <mulgor@gmail.com> wrote in message <51eed7b0-594c-4f24-b07b-1614011a9a95@googlegroups.com>...
> > > On Monday, October 7, 2013 2:51:09 AM UTC+13, Poulomi wrote:
> > > > Hi,
> > > >
> > > >
> > > >
> > > > I have 1000 station data points across US, for which I have precipitation data. I need to plot contour map of precipitation distribution across US from these 1000 station data. I used foll. code for that:
> > > >
> > > >
> > > >
> > > > [LatGrid, LonGrid] = meshgrid(linspace(min(Lat_US), max(Lat_US)), ...
> > > >
> > > > linspace(min(Lon_US), max(Lon_US)));
> > > >
> > > >
> > > >
> > > > Severity_grid = griddata(Lat_US, Lon_US, Srty_10yr_US, LatGrid, LonGrid);
> > > >
> > > > contourm(LatGrid, LonGrid, Severity_grid);colorbar;
> > > >
> > > >
> > > >
> > > > but few contour lines are falling outside CONUS map; can anybody kindly let me know how to remove these contour lines outside US map. Thanks in advance...
> > >
> > > Set the nodes outside your area of interest to NaN.
> > Thanks, but I am using griddata, which is interpolating the data points, how I can identify which of the co-ordinates are falling outside US domain. Kindly let me know some sample example, will be useful. Thanks

Indeed useful. Thanks a lot :)

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us