Thread Subject: scatter data on a map

Subject: scatter data on a map

From: Travis

Date: 17 Feb, 2010 21:54:05

Message: 1 of 8

I have the mapping toolbox, a georeferenced .tif file and data with lat/long and I can't for the life of me figure out how to plot the data onto the image. I have gone through many of the examples in the mapping toolbox, and still no glory. Any help would be greatly appreciated.

Subject: scatter data on a map

From: Andrew Stevens

Date: 18 Feb, 2010 00:50:21

Message: 2 of 8

"Travis " <sinusoid2@hotmail.com> wrote in message <hlhoht$hqo$1@fred.mathworks.com>...
> I have the mapping toolbox, a georeferenced .tif file and data with lat/long and I can't for the life of me figure out how to plot the data onto the image. I have gone through many of the examples in the mapping toolbox, and still no glory. Any help would be greatly appreciated.

Travis,

Do you have the .tfw (world file) for your image? If so, you could try this:

im=imread('foo.tif');
r=wolrdfileread('foo.tfw');
[xim,yim]=pixcenters(r,size(im));

figure
imagesc(xim,yim,im);
set(gca,'ydir','normal',...
   'da',[1 1 1])

Note that this is plotting the data on a regular axes, not a map axes (which I have found to be cumbersome to deal with).

-Andrew

Subject: scatter data on a map

From: Travis

Date: 18 Feb, 2010 23:12:04

Message: 3 of 8

"Andrew Stevens" <astevens@JUNKusgs.gov> wrote in message <hli2sd$cvm$1@fred.mathworks.com>...
> "Travis " <sinusoid2@hotmail.com> wrote in message <hlhoht$hqo$1@fred.mathworks.com>...
> > I have the mapping toolbox, a georeferenced .tif file and data with lat/long and I can't for the life of me figure out how to plot the data onto the image. I have gone through many of the examples in the mapping toolbox, and still no glory. Any help would be greatly appreciated.
>
> Travis,
>
> Do you have the .tfw (world file) for your image? If so, you could try this:
>
> im=imread('foo.tif');
> r=wolrdfileread('foo.tfw');
> [xim,yim]=pixcenters(r,size(im));
>
> figure
> imagesc(xim,yim,im);
> set(gca,'ydir','normal',...
> 'da',[1 1 1])
>
> Note that this is plotting the data on a regular axes, not a map axes (which I have found to be cumbersome to deal with).
>
> -Andrew

This works well, but when I do a colorbar it default to 0:255 with the map colors, and the data points follor that colorsystem. Is there a way to change this?

Subject: scatter data on a map

From: Travis

Date: 19 Feb, 2010 16:59:07

Message: 4 of 8

"Travis " <sinusoid2@hotmail.com> wrote in message <hlkhg4$qi6$1@fred.mathworks.com>...
> "Andrew Stevens" <astevens@JUNKusgs.gov> wrote in message <hli2sd$cvm$1@fred.mathworks.com>...
> > "Travis " <sinusoid2@hotmail.com> wrote in message <hlhoht$hqo$1@fred.mathworks.com>...
> > > I have the mapping toolbox, a georeferenced .tif file and data with lat/long and I can't for the life of me figure out how to plot the data onto the image. I have gone through many of the examples in the mapping toolbox, and still no glory. Any help would be greatly appreciated.
> >
> > Travis,
> >
> > Do you have the .tfw (world file) for your image? If so, you could try this:
> >
> > im=imread('foo.tif');
> > r=wolrdfileread('foo.tfw');
> > [xim,yim]=pixcenters(r,size(im));
> >
> > figure
> > imagesc(xim,yim,im);
> > set(gca,'ydir','normal',...
> > 'da',[1 1 1])
> >
> > Note that this is plotting the data on a regular axes, not a map axes (which I have found to be cumbersome to deal with).
> >
> > -Andrew
>
> This works well, but when I do a colorbar it default to 0:255 with the map colors, and the data points follor that colorsystem. Is there a way to change this?

OK, my last message seems vague to me now. What I am trying to do is have the colorbar apply only to the data I plot on the map/image, and not to the map/image itself. That would scale the colorbar properly from the start.

Subject: scatter data on a map

From: Andrew Stevens

Date: 19 Feb, 2010 20:49:04

Message: 5 of 8

"Travis " <sinusoid2@hotmail.com> wrote in message <hlmg0r$gvm$1@fred.mathworks.com>...
> "Travis " <sinusoid2@hotmail.com> wrote in message <hlkhg4$qi6$1@fred.mathworks.com>...
> > "Andrew Stevens" <astevens@JUNKusgs.gov> wrote in message <hli2sd$cvm$1@fred.mathworks.com>...
> > > "Travis " <sinusoid2@hotmail.com> wrote in message <hlhoht$hqo$1@fred.mathworks.com>...
> > > > I have the mapping toolbox, a georeferenced .tif file and data with lat/long and I can't for the life of me figure out how to plot the data onto the image. I have gone through many of the examples in the mapping toolbox, and still no glory. Any help would be greatly appreciated.
> > >
> > > Travis,
> > >
> > > Do you have the .tfw (world file) for your image? If so, you could try this:
> > >
> > > im=imread('foo.tif');
> > > r=wolrdfileread('foo.tfw');
> > > [xim,yim]=pixcenters(r,size(im));
> > >
> > > figure
> > > imagesc(xim,yim,im);
> > > set(gca,'ydir','normal',...
> > > 'da',[1 1 1])
> > >
> > > Note that this is plotting the data on a regular axes, not a map axes (which I have found to be cumbersome to deal with).
> > >
> > > -Andrew
> >
> > This works well, but when I do a colorbar it default to 0:255 with the map colors, and the data points follor that colorsystem. Is there a way to change this?
>
> OK, my last message seems vague to me now. What I am trying to do is have the colorbar apply only to the data I plot on the map/image, and not to the map/image itself. That would scale the colorbar properly from the start.

Travis,

One option is to convert the image to RGB. I do this routinely using REAL2RGB, available on the file exchange. Once your image is RGB, the colormap and 'clim' property of the axis no longer applies.

-Andrew

Subject: scatter data on a map

From: Travis

Date: 19 Feb, 2010 23:04:04

Message: 6 of 8

"Andrew Stevens" <astevens@JUNKusgs.gov> wrote in message <hlmtg0$lf2$1@fred.mathworks.com>...
> "Travis " <sinusoid2@hotmail.com> wrote in message <hlmg0r$gvm$1@fred.mathworks.com>...
> > "Travis " <sinusoid2@hotmail.com> wrote in message <hlkhg4$qi6$1@fred.mathworks.com>...
> > > "Andrew Stevens" <astevens@JUNKusgs.gov> wrote in message <hli2sd$cvm$1@fred.mathworks.com>...
> > > > "Travis " <sinusoid2@hotmail.com> wrote in message <hlhoht$hqo$1@fred.mathworks.com>...
> > > > > I have the mapping toolbox, a georeferenced .tif file and data with lat/long and I can't for the life of me figure out how to plot the data onto the image. I have gone through many of the examples in the mapping toolbox, and still no glory. Any help would be greatly appreciated.
> > > >
> > > > Travis,
> > > >
> > > > Do you have the .tfw (world file) for your image? If so, you could try this:
> > > >
> > > > im=imread('foo.tif');
> > > > r=wolrdfileread('foo.tfw');
> > > > [xim,yim]=pixcenters(r,size(im));
> > > >
> > > > figure
> > > > imagesc(xim,yim,im);
> > > > set(gca,'ydir','normal',...
> > > > 'da',[1 1 1])
> > > >
> > > > Note that this is plotting the data on a regular axes, not a map axes (which I have found to be cumbersome to deal with).
> > > >
> > > > -Andrew
> > >
> > > This works well, but when I do a colorbar it default to 0:255 with the map colors, and the data points follor that colorsystem. Is there a way to change this?
> >
> > OK, my last message seems vague to me now. What I am trying to do is have the colorbar apply only to the data I plot on the map/image, and not to the map/image itself. That would scale the colorbar properly from the start.
>
> Travis,
>
> One option is to convert the image to RGB. I do this routinely using REAL2RGB, available on the file exchange. Once your image is RGB, the colormap and 'clim' property of the axis no longer applies.
>
> -Andrew

I have the image as a .tif file right now. I Import it with the code provided above, and it comes in as an XxYx3 uint8, which is what it looks like real2rgb does. I have the mapping toolbox, but I cannot find a way to do this in there either.

Subject: scatter data on a map

From: Andrew Stevens

Date: 20 Feb, 2010 00:19:04

Message: 7 of 8

"Travis " <sinusoid2@hotmail.com> wrote in message <hln5d4$l59$1@fred.mathworks.com>...
> "Andrew Stevens" <astevens@JUNKusgs.gov> wrote in message <hlmtg0$lf2$1@fred.mathworks.com>...
> > "Travis " <sinusoid2@hotmail.com> wrote in message <hlmg0r$gvm$1@fred.mathworks.com>...
> > > "Travis " <sinusoid2@hotmail.com> wrote in message <hlkhg4$qi6$1@fred.mathworks.com>...
> > > > "Andrew Stevens" <astevens@JUNKusgs.gov> wrote in message <hli2sd$cvm$1@fred.mathworks.com>...
> > > > > "Travis " <sinusoid2@hotmail.com> wrote in message <hlhoht$hqo$1@fred.mathworks.com>...
> > > > > > I have the mapping toolbox, a georeferenced .tif file and data with lat/long and I can't for the life of me figure out how to plot the data onto the image. I have gone through many of the examples in the mapping toolbox, and still no glory. Any help would be greatly appreciated.
> > > > >
> > > > > Travis,
> > > > >
> > > > > Do you have the .tfw (world file) for your image? If so, you could try this:
> > > > >
> > > > > im=imread('foo.tif');
> > > > > r=wolrdfileread('foo.tfw');
> > > > > [xim,yim]=pixcenters(r,size(im));
> > > > >
> > > > > figure
> > > > > imagesc(xim,yim,im);
> > > > > set(gca,'ydir','normal',...
> > > > > 'da',[1 1 1])
> > > > >
> > > > > Note that this is plotting the data on a regular axes, not a map axes (which I have found to be cumbersome to deal with).
> > > > >
> > > > > -Andrew
> > > >
> > > > This works well, but when I do a colorbar it default to 0:255 with the map colors, and the data points follor that colorsystem. Is there a way to change this?
> > >
> > > OK, my last message seems vague to me now. What I am trying to do is have the colorbar apply only to the data I plot on the map/image, and not to the map/image itself. That would scale the colorbar properly from the start.
> >
> > Travis,
> >
> > One option is to convert the image to RGB. I do this routinely using REAL2RGB, available on the file exchange. Once your image is RGB, the colormap and 'clim' property of the axis no longer applies.
> >
> > -Andrew
>
> I have the image as a .tif file right now. I Import it with the code provided above, and it comes in as an XxYx3 uint8, which is what it looks like real2rgb does. I have the mapping toolbox, but I cannot find a way to do this in there either.

If your image is already RGB, then the figure's colormap should not affect it's display. You may just want to adjust the 'clim' property of your axis:

set(gca,'clim',[cmin cmax]) %cmin and cmax are the color limits you want to apply

or

caxis([cmin cmax])

-Andrew

Subject: scatter data on a map

From: Travis

Date: 22 Feb, 2010 15:46:02

Message: 8 of 8

"Andrew Stevens" <astevens@JUNKusgs.gov> wrote in message <hln9po$qep$1@fred.mathworks.com>...
> "Travis " <sinusoid2@hotmail.com> wrote in message <hln5d4$l59$1@fred.mathworks.com>...
> > "Andrew Stevens" <astevens@JUNKusgs.gov> wrote in message <hlmtg0$lf2$1@fred.mathworks.com>...
> > > "Travis " <sinusoid2@hotmail.com> wrote in message <hlmg0r$gvm$1@fred.mathworks.com>...
> > > > "Travis " <sinusoid2@hotmail.com> wrote in message <hlkhg4$qi6$1@fred.mathworks.com>...
> > > > > "Andrew Stevens" <astevens@JUNKusgs.gov> wrote in message <hli2sd$cvm$1@fred.mathworks.com>...
> > > > > > "Travis " <sinusoid2@hotmail.com> wrote in message <hlhoht$hqo$1@fred.mathworks.com>...
> > > > > > > I have the mapping toolbox, a georeferenced .tif file and data with lat/long and I can't for the life of me figure out how to plot the data onto the image. I have gone through many of the examples in the mapping toolbox, and still no glory. Any help would be greatly appreciated.
> > > > > >
> > > > > > Travis,
> > > > > >
> > > > > > Do you have the .tfw (world file) for your image? If so, you could try this:
> > > > > >
> > > > > > im=imread('foo.tif');
> > > > > > r=wolrdfileread('foo.tfw');
> > > > > > [xim,yim]=pixcenters(r,size(im));
> > > > > >
> > > > > > figure
> > > > > > imagesc(xim,yim,im);
> > > > > > set(gca,'ydir','normal',...
> > > > > > 'da',[1 1 1])
> > > > > >
> > > > > > Note that this is plotting the data on a regular axes, not a map axes (which I have found to be cumbersome to deal with).
> > > > > >
> > > > > > -Andrew
> > > > >
> > > > > This works well, but when I do a colorbar it default to 0:255 with the map colors, and the data points follor that colorsystem. Is there a way to change this?
> > > >
> > > > OK, my last message seems vague to me now. What I am trying to do is have the colorbar apply only to the data I plot on the map/image, and not to the map/image itself. That would scale the colorbar properly from the start.
> > >
> > > Travis,
> > >
> > > One option is to convert the image to RGB. I do this routinely using REAL2RGB, available on the file exchange. Once your image is RGB, the colormap and 'clim' property of the axis no longer applies.
> > >
> > > -Andrew
> >
> > I have the image as a .tif file right now. I Import it with the code provided above, and it comes in as an XxYx3 uint8, which is what it looks like real2rgb does. I have the mapping toolbox, but I cannot find a way to do this in there either.
>
> If your image is already RGB, then the figure's colormap should not affect it's display. You may just want to adjust the 'clim' property of your axis:
>
> set(gca,'clim',[cmin cmax]) %cmin and cmax are the color limits you want to apply
>
> or
>
> caxis([cmin cmax])
>
> -Andrew
Occam's Razor strikes again. Thanks, that works perfectly Andrew.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
geotiff Andrew Stevens 17 Feb, 2010 19:54:08
pixcenters Andrew Stevens 17 Feb, 2010 19:54:08
rssFeed for this Thread

Contact us at files@mathworks.com