# How To Plot a Histogram with updated geometry

Hello,

I want to create histograms which uses a mask - I know how to do this. With the “Analysis” > “Histogram” Tool and then I can use a mask or not. And I want to use my geometry-mask, which I created with the “Polygon drawing tool”.
I recognized that the data, which is used by the histogram or rather the histogram doesn’t change when I change my mask.
I show you my work, so it its better to understand what I mean.

I want to know the values of the marked areas, e.g. the ice floes. Thus I create a histogram.

To demonstrate my problem I draw a new geometry with a lead - which have different values.

I closed my before created histogram an want to calculate a new one, which includes the values of the new geometry as well. I use only one vector data container.

And here you see my problem. It is exactly the same histogram as above without the new geometry. I think it is the histogram of my very first geometry, which I draw with the polygon drawing tool. And there is no possibility to update this histogram. Or I don’t know it. I thought it would update the histogram.

How can I solve my problem?
Thank you.

Does your “geometry” consist of several polygons at once?
Then it would be no wonder why dark areas are not present to a larger degree. Looking at it I would assume the same proportions of bright and dark pixels for your pink polygons and for the whole image.

Also don’t forget to re-calculate the histogram on (maybe you’ll have to change the number of bins so the symbol becomes active again.

You can also use the statistics tool in order to check if the number of pixels changes using the ROI or not.

It works for me:
The first histogram:

After adding another geometry and pressing re-calculate:

Maybe the change is not huge enough to be visible.
Do you know that you can zoom in into the diagram?
Draw a rectangle from the upper-left to the lower right corner. To zoom out draw the rectangle from right to left.
Or adjust the axis values on the right.

@ABraun I try to re-calculate every time I change something in my geometry. And yes, my geometry consist of several polygons. The Tip with the bin number is great. Thank you.
And now, I used the statistics-tool. And this seems to work very well.

I tested everything a second time, with screen shots, because my histogram doesn’t change.

I draw around one ice floe. And I got the following pics:

And I exported the histogram data with “copy data to clipboard” to a .txt file: Scholle1.txt (21.4 KB)

Then I draw a second ice floe and got the following pics:

The number of pixels of the ROI data in the statistic tool changed. And the histogram as well.

But the histogram in the histogram tool didn’t change. Even if I use the re-calculate tip with changing the bin number. To confirm my feeling that there is something wrong I saved the histogram data in a .txt file as well: Scholle1.txt (21.4 KB) and if you compare these two data-sets you will see that there are exactly the same.

While I was doing all this stuff I noticed the error-sign at the bottom rigth corner in SNAP. The Details are:

java.lang.IllegalArgumentException: Invalid number of points in LinearRing (found 3 - must be 0 or >= 4)
at com.vividsolutions.jts.geom.LinearRing.validateConstruction(LinearRing.java:114)
at com.vividsolutions.jts.geom.LinearRing.(LinearRing.java:106)
at com.vividsolutions.jts.geom.GeometryFactory.createLinearRing(GeometryFactory.java:341)
at com.vividsolutions.jts.geom.GeometryFactory.createLinearRing(GeometryFactory.java:328)
at org.esa.snap.core.util.AwtGeomToJtsGeomConverter.createLinearRingList(AwtGeomToJtsGeomConverter.java:91)
at org.esa.snap.core.util.AwtGeomToJtsGeomConverter.createPolygon(AwtGeomToJtsGeomConverter.java:66)
at org.esa.snap.ui.product.SimpleFeatureShapeFigure.getGeometryFromShape(SimpleFeatureShapeFigure.java:136)
at org.esa.snap.ui.product.SimpleFeatureShapeFigure.setShape(SimpleFeatureShapeFigure.java:121)
at com.bc.ceres.swing.figure.interactions.InsertMultiPointFigureInteractor.mouseClicked(InsertMultiPointFigureInteractor.java:82)
at com.bc.ceres.swing.figure.InteractionDispatcher.mouseClicked(InteractionDispatcher.java:55)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:269)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:269)
at java.awt.Component.processMouseEvent(Component.java:6536)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4534)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access\$500(EventQueue.java:97)
at java.awt.EventQueue\$3.run(EventQueue.java:709)
at java.awt.EventQueue\$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain\$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain\$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue\$4.run(EventQueue.java:731)
at java.awt.EventQueue\$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain\$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)

I don’t know if this belongs to my problem, but it shows up if I only do this kind of things.

If I can copy the whole histogram data out of the statistics tool the problem with the histogram tool wouldn’t bother me this much. But I’m only able to copy the table (upper left corner) to a .cvs file.

EDIT: I uploaded the wrong picture at one point. Just fixed this.

I saw this exception too. But only once while drawing a geometry. I think it is not the cause of the histogram problem.
I also noticed that both histogram images are named Scholle1_histo.png. Did you upload the same image twice?
Every time I try it my histogram gets updated.
I send you a separate message with a location where you can upload the data. So I can try to reproduce it.

Ups. I uploaded one time the false image. I corrected this in my post before. But at the end: the histograms are the same.

For all users.
We have investigated this issue further. But Mara and I haven’t the cause of it.
It was also not able to reproduce it. I don’t doubt Mara, she has this problem but I can’t reproduce.
Has someone else observed it? Maybe some more input from someone else might give a clue.