Matlab - area values into raster data

In summary, the author is trying to transform area values into raster data. He has areas, defined as circles (location of center + length of radius). Each area has a designated value between 0 and 2. He used Matlab's command area to plot the areas and also to designate the value that goes with each area. Now he wants to transport this into raster data so he can plot it using pcolor. The problem is that when his areas were squares, the values looked boxy. So he abandoned square areas and went to circles. He assigned magnitude to each circle and then tried to plot the color-coded plot using pcolor function. However, the spatial sparcity of the events works against him as most of the
  • #1
MartinV
69
0
I'm trying to transform area values into raster data.

I have areas, defined as circles (location of center + length of radius). Each area has a designated value between 0 and 2. I used Matlab's command area to plot the areas and also to designate the value that goes with each area. Now I want to transport this into raster data so I can plot it using pcolor.

When my areas were squares, I could simply type this:
Net(-1*(Loc(1,2)-50)/10*L+1:-1*(Loc(1,2)-50)/10*L+L/2^2+1, (Loc(1,1)+82)/10*L+1:(Loc(1,1)+82)/10*L +L/2^2+1) = Data3(1,2);

The pixels in Net were designated with the value from Data3 but there should be a more elegant way to do this with Matlab, I just don't know what it is.

Any suggestions?
 
Physics news on Phys.org
  • #3
This doesn't look like it has anything to do with what I'm trying to do. Maybe I need to try explaining it again.

I have a dataset of events that have geographical coordinates and a magnitude. The location plot looks like this:
MainPlot_zps6d0eedd8.png


Some areas are very densely populated, some are sparsely. To get the feel of the magnitude of these events, I've made a grid and put each event into its own pixel. The pcolor function gives me this color-coded plot:

ColorCodedMap250_zpsf5ac5723.png


Again, the spatial sparcity of the events works against me as most of the picture is just grey (0 value). So the idea was to assign areas and come up with an average magnitude for that area that all events in that area contribute into. The first idea was to use squares; using pcolor for color-coding this is what came up:

ColormapTest_zps98decef2.png


This plot lacked fluency so I used interpolation to make the transition between areas smoother. This is what I got, again using pcolor function:

InterpTest2_zps0b0118da.png


Now I realized that the boxiness of the areas felt false so I abandoned square areas and went to circles. This are the circles I designated:

CircleTest1_zpsf8e5547e.png


Each circle has its magnitude assigned, now I want to put those values down into a matrix so I can use pcolor again in hope that it will look like the over-boxy color-coded picture above.

Since this is all geographically based, I need to plot that final color-coded plot on top of a map but that comes later.
 
  • #4
1) Are the circles (a) a sampled region in which you count the number of events (and that's your magnitude) or (b) is the magnitude encoded in the size of the circles?

2) If a), how do you interpret overlap then? Aren't you counting events more than once where there's overlap?
 
  • #5
Yes, circles overlap and some events are taken multiple times. I intend to draw the big circles first and then smaller on top of them so the values of pixels would be overwritten.
 
  • #6
That's one wants to implement it. I think there's a better way, though

Another question. In your original pcolor image, what do the magnitude (color) of individual points represent? Are events not binary?
 
  • #7
All events have a magnitude with values the colorbar shows. The color coding represents that magnitude.

My point is that making squares in a matrix is easy because Matlab's way of assigning values to elements makes it natural A(123:321,123:321) = 2. This instantly makes a square. Right now I'm tryin to do it by using a statement like this:

sqrt((x0 - x).^2 + (y0 - x).^2) <= R;

However, I have to use a loop in a loop to go through all rows and columns, assigning value to each element. since this is a 1000×1000 matrix and I have 136 circles to mount, this might take a long time.

Is there a more elegant way than what I just described?
 
Last edited:

1. What is Matlab and how does it convert area values into raster data?

Matlab is a programming language and software environment commonly used for scientific and technical computing. It has functions and tools that allow for the conversion of area values into raster data, which is a type of digital image made up of a grid of pixels.

2. Can Matlab handle large datasets when converting area values into raster data?

Yes, Matlab has the ability to handle large datasets and can efficiently convert area values into raster data for these datasets. It has built-in functions for data management and processing that can handle large amounts of data.

3. What are the steps for converting area values into raster data in Matlab?

The general steps for converting area values into raster data in Matlab are as follows:
1. Define the area of interest and create a grid of points.
2. Assign values to each point based on the area values.
3. Use the grid of points and values to create a raster data array.
4. Visualize the raster data using built-in Matlab functions or export it for further analysis.

4. Can I customize the raster data output in Matlab for my specific needs?

Yes, Matlab allows for customization of the raster data output to fit specific needs. Users can define the grid size, resolution, and format of the raster data. They can also apply various functions and algorithms to manipulate the raster data for their desired output.

5. Are there any alternatives to Matlab for converting area values into raster data?

Yes, there are other software and programming languages that can also convert area values into raster data. Some examples include Python, R, and ArcGIS. However, Matlab is a popular choice among scientists due to its extensive toolboxes and built-in functions for data analysis and visualization.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
127
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
Back
Top