1

I'm totally new to Octave but thought I'd give it a try since I need to create a box and whisker plot from a raster image with height values.

I've managed to export my GeoTIFF image to some sort of .CSV-file, it can be accessed from here and it uses "." for decimals and ";" as the delimiter between cells.

When I run dlmread ("test.csv",, ";", 0, 0) the results indicate that the data is split up in multiple columns? And on top of that I have zero-values (0) which isn't present in test.csv, see screenshot below from Octave: enter image description here

First of all I was under the impression that to create a box and whisker plot I needed to have the data in one column, not a couple of hundred like in this case. And secondly; what am I doing wrong when I'm getting all these zeroes?

Could someone point out how to properly import the above CSV to octave. And if you feel really generous I would be so thankful if you also could help me to create a box and whisker plot from the attached data.

I'm using Octave 4.2.1 x86_64 on Windows 10 home.

johlund
  • 137
  • 7
  • this is not a typical CSV file because the number of columns is not constant. it is even increasing every line. How have you created this file? – Andy Jan 04 '18 at 18:09
  • and btw, Octave can read TIFF – Andy Jan 04 '18 at 18:19
  • I'm using QGIS and 1) gdalwarp to clip and set nodata-value, 2) then gdal_translate -of aaigrid to get a .asc-file with a 4-5 row header and blank space delimiters, then finally 3) I search and replace the asc-file blank spaces with semicolons and removed all nodata-values. I tried and succeded in loading a raster with Octave but it only contained two values (zeros on nodata-vaules and the value 253 if I remember correctly on valid pixelns, like some sort of colour-thing). That in combination with that I couldn't find how to remove nodata-values made me give up and try this approach. – johlund Jan 04 '18 at 23:52
  • without a concrete, runnable script it's impossible to help you. I also think this is a XY problem because basically you want to use a GeoTIFF in Octave and you just think that your way going through different exports/CSV would be a good idea – Andy Jan 05 '18 at 06:55
  • Xy problem? All i wanna do is create a box and whisker plot from the values found in the "fake csv", the coordinates (xy) is not of interest and thats why I removed the header with xy info. I'gladly supply everything if it can help you help me, but I dont not what a concrete runnable script even is. The Octave + tiff thing is a another question but since you brought it up I'd thought I mention that I've tried and failed. Here the question remains - is it possible to load the attached "csv file" and use it for a box and whisker? Is there another dlmread command that can do the trick etc? – johlund Jan 05 '18 at 07:25
  • And, thanks a lot for trying to help! – johlund Jan 05 '18 at 07:25
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/162579/discussion-between-andy-and-user1151640). – Andy Jan 05 '18 at 09:33

1 Answers1

2

It's really difficult to figure out what you really want and it might be much easier to use the GeoTIFF directly without needing to go through multiple (yet obscure) conversions.

But here is a wild guess:

pkg load statistics

s = urlread ("https://drive.google.com/uc?export=download&id=1RzJ-EO0OXgfMmMRG8wiCBz-51RcwSM5h");
o = str2double (strsplit (s, ";"));
o(isnan (o)) = [];

subplot (3, 1, 1);
plot (o)
grid on

subplot (3, 1, 2);
hist (o, 100);

subplot (3, 1, 3);
boxplot (o)

print out.png

gives you the raw data, the histogram and a boxplot with center, spread, departure from symmetry and whiskers:

plot

Andy
  • 7,931
  • 4
  • 25
  • 45
  • Wow, I'm so impressed by how easy you can handle Octave (even with an online file like that) and how good looking the results are - inspiring! I'm sorry for the lack of guidance to "what I really" want, let me update the question with some background info and attach the GeoTIFF if you think that's easier to work with. – johlund Jan 05 '18 at 12:12
  • While waiting for the update (working on that right now) the desired results I want is the exact box plot above except without the x-axis. Or in other words stack all the values found in in the fake csv-file in ONE column and produce the same box plot (with no x-axis). – johlund Jan 05 '18 at 12:17
  • Question updated with more background info and a GeoTIFF example. – johlund Jan 06 '18 at 12:44
  • @johlund: to remove the tick marks of the x-axis simply `set(gca,'xtick’,[])`. You might want to set the xtick property to 1, to have a tick at the box. – Cris Luengo Jan 14 '18 at 03:24
  • @CrisLuengo thank you for pointing out how to visually remove them. But what are the current ticks (spread from 0,6-1,4) representing and from where is that data collected? As you've probably seen from the sketch in the question you commented on (where you asked if stackexchange has become a code writing service), my aim is to show 30 box and whisker plots simultaneously. Sorry for my total lack of knowledge. – johlund Jan 14 '18 at 06:02
  • @johlund: MATLAB `axes` objects always have an x axis and a y axis. There is no way to draw something in 2D without specifying (x,y) locations. The `boxplot` command plots boxes (can plot multiple ones if the input has multiple columns, see `help boxplot`) at integer locations, and the boxes extend to the left and right by some amount (configurable, see docs). The horizontal axis here doesn't contain any data, the 0.4 distance from the center of the box is simply the default box size. Changing the size of the window will change the aspect ratio of the box. – Cris Luengo Jan 14 '18 at 06:10
  • @johlund: See [this question](https://stackoverflow.com/questions/29784601/swapping-x-y-axis-in-matlab) for how to turn the plot so that the boxes of your box plot are horizontal (second option in the answer). – Cris Luengo Jan 14 '18 at 06:13
  • @CrisLuengo: Thank you very much for excellent and helpful answers. I've managed to turn the plot but the set(gca, 'xstick', []) didn't work. "Set" turns blue in Octave editor and nothing happens when I run the code. Ideas? – johlund Jan 14 '18 at 06:49
  • @johlund : MATLAB automatically sets the `'XTickMode'` property to `'manual'` when you set `'XTick'`, maybe that is missing in Octave? Octave treats `"` and `'` identically as far as I know, it's strange that that would make a difference. Just making sure: you write "xstick" in your comment. Is this an autocorrect typo? The property name is "xtick" (actually "XTick" but case is usually irrelevant). – Cris Luengo Jan 14 '18 at 14:23
  • Xstick was - like you suspected - a typo, see my related question here for copy/paste of the Octave code: https://stackoverflow.com/questions/48195145/octave-box-and-whisker-plot-without-spread-from-geotiff The only two thing left to resolve with the box plot visualisation is to invert the x-axis (view([-90 90] made to scale go from 450-200 and I want it to go from 200-450) and to insert labels for each box plot. – johlund Jan 14 '18 at 15:04