Unable to solve error both types of region are specified: pixel and geometry. At most one must be specified

I am downloading a S2 product and would like to process it using the graph (mostly to learn how the graph works and to integrate it with Snappy later on).

I have 4 nodes currently but have worked only on the first two, namely Read and Reproject. I connected everything since the Graph Builder would otherwise just show Graph incomplete, without actually checking any other errors/discrepancies.

In the Read node I have selected Bands B2-B8. Everything else is default.

Once I connected Reproject (also tried with Subset), I got

Error: [NodeId: Read] Both types of region are specified: pixel and geometry. At most one must be specified

Given that I am working with radio buttons (a GUI element where a single choice needs to be made, unlike checkboxes) and I have specifically selected Geographic coordinates, I really cannot see where the problem is coming from. Or perhaps the errors is from somewhere else?

The full Graph XML:

<graph id="Graph">
  <version>1.0</version>
  <node id="BandMerge">
    <operator>BandMerge</operator>
    <sources>
      <sourceProduct refid="Subset"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <sourceBands/>
      <geographicError>1.0E-5</geographicError>
    </parameters>
  </node>
  <node id="Subset">
    <operator>Subset</operator>
    <sources>
      <sourceProduct refid="Read"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <sourceBands/>
      <tiePointGrids/>
      <region>0,0,1,1</region>
      <referenceBand/>
      <geoRegion/>
      <subSamplingX>1</subSamplingX>
      <subSamplingY>1</subSamplingY>
      <fullSwath>false</fullSwath>
      <copyMetadata>false</copyMetadata>
    </parameters>
  </node>
  <node id="Read">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <useAdvancedOptions>true</useAdvancedOptions>
      <file>/home/user/Projects/data/product/S2A_MSIL2A_20220812T103031_N0400_R108_T32UMV_20220812T182800.SAFE/MTD_MSIL2A.xml</file>
      <geometryRegion>POLYGON ((7.61434268951416 49.644386291503906, 7.8043413162231445 49.64650344848633, 7.99436092376709 49.648311614990234, 8.18439769744873 49.64980697631836, 8.374448776245117 49.6509895324707, 8.564510345458984 49.651859283447266, 8.7545804977417 49.65241622924805, 8.944653511047363 49.65266418457031, 9.13472843170166 49.6525993347168, 9.135144233703613 49.6525993347168, 9.134803771972656 49.52919387817383, 9.134465217590332 49.40578079223633, 9.134129524230957 49.282371520996094, 9.133795738220215 49.15895462036133, 9.133464813232422 49.03553771972656, 9.133135795593262 48.91211700439453, 9.132808685302734 48.7886962890625, 9.132484436035156 48.6652717590332, 9.13248348236084 48.665000915527344, 9.132076263427734 48.665000915527344, 8.945743560791016 48.665061950683594, 8.759411811828613 48.664825439453125, 8.573083877563477 48.664283752441406, 8.386763572692871 48.66344451904297, 8.20045280456543 48.66230010986328, 8.014155387878418 48.660858154296875, 7.827874660491943 48.65911102294922, 7.641613006591797 48.657066345214844, 7.641605854034424 48.6573371887207, 7.638278484344482 48.78072738647461, 7.6349287033081055 48.904117584228516, 7.631556034088135 49.02750015258789, 7.62816047668457 49.150882720947266, 7.624741554260254 49.27426528930664, 7.621298789978027 49.397640228271484, 7.617832660675049 49.52101516723633, 7.61434268951416 49.644386291503906))</geometryRegion>
      <formatName>SENTINEL-2-MSI-MultiRes-UTM32N</formatName>
      <copyMetadata>true</copyMetadata>
      <bandNames>B2,B3,B4,B5,B6,B7</bandNames>
      <pixelRegion>0,0,10980,10980</pixelRegion>
      <maskNames/>
    </parameters>
  </node>
  <node id="Write">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="BandMerge"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>/home/user/Projects/TEMP/target.dim</file>
      <formatName>BEAM-DIMAP</formatName>
    </parameters>
  </node>
  <applicationData id="Presentation">
    <Description/>
    <node id="BandMerge">
      <displayPosition x="337.0" y="184.0"/>
    </node>
    <node id="Subset">
      <displayPosition x="163.0" y="167.0"/>
    </node>
    <node id="Read">
      <displayPosition x="58.0" y="113.0"/>
    </node>
    <node id="Write">
            <displayPosition x="510.0" y="141.0"/>
    </node>
  </applicationData>
</graph>

Hello,
First of all, you already used a subset reading, when using Read advanced options.
In your graph xml the Read operator has a geometryRegion and also pixelRegion. You should keep only one of them.
Not sure how your graph ended like this …
After, if you already used a subset reading, there’s no need of another Subset chained operator.
Band Merge is used for merging bands from several products into one product, so I don’t understand why it was used here, you have only one product.

E.g. the Read operator should look like this in your xml graph:

<node id="Read">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <useAdvancedOptions>true</useAdvancedOptions>
      <file>path\to\S2A_MSIL1C_20191003T090811_N0208_R050_T35UPS_20191003T103342.SAFE\MTD_MSIL1C.xml</file>
      <copyMetadata>true</copyMetadata>
      <bandNames>B2,B3,B4,B5,B6,B7</bandNames>
      <pixelRegion>0,0,10980,10980</pixelRegion>
      <maskNames/>
    </parameters>
  </node>

Hi.

In your graph xml the Read operator has a geometryRegion and also pixelRegion. You should keep only one of them.
Not sure how your graph ended like this …

Me neither. :smile: I tried creating a new one yet the same problem keeps pestering me. Initially I was just reloading my test graph but after half an hour of this, I decided to create a bunch of new ones with very basic pipeline in them.

I think this is a bug. I did not manually edit the XML of the graph and just selected the other radio button. Still, both options are in the XML document, which should not be the case at least if one is using just the GUI and not manually writing the graph.

After, if you already used a subset reading, there’s no need of another Subset chained operator.

It depends. For example if I were to add a TileWriter (e.g. for writing PNG tiles that can then be hosted via a GIS server), it has a limited number of tiles it can split a region into (256 if I remember correctly). So if you want a larger region with small tiles, you need to add multiple Subset operators and divide the large region into smaller ones until you reach the required tile granularity.

Band Merge is used for merging bands from several products into one product, so I don’t understand why it was used here, you have only one product.

Hmm, I don’t think so. Correct me if I am wrong, but isn’t BandMerge also for merging separate bands into a single one? (hence the name) For example if I want to create an RGB image from a Sentinel 2 product, I would have to merge B4, B3 and B2 (Red, Green and Blue channel). There are of course many other band combinations that one can make to outline specific things.

In any case anything after the Reproject (except for Write) is currently not an issue. My graph fails at the very first step, namely Read.

Hmmm, I tried changing the XML manually to remove the <pixelRegion/>. However, once I load the file into the GUI, the Advanced options need to be opened again (it does not detect that I have used those from the XML) and Pixel Coordinates is yet again selected. Selecting the other option leads to the same issue. This really looks like a bug to me.

Yes, as I told you, the error came from the Read operator, the first one from the graph. The rest … from the simple example you posted I couldnt figure out what you was trying to do.

Are you using SNAP 9 with latest updates? We will try to see if we can reproduce the Read operator behavior. At first try, this doesn’t happen (e.g. I don’t have both type of region in the xml)

image

image

image

1 Like

Then please try with just Read-> Write, and after File-> View Graph xml and describe the steps, maybe I’m missing something:
(the pixel and geographic coordinates are always synchronized, so if you change the pixel region the geographic coordinates will update accordindly, and vice-versa; but I’m still seeing only one in the xml)

If I never touch the option Geographic Coordinates, I also don’t get the above mentioned error:

The XML looks like this:

<graph id="Graph">
  <version>1.0</version>
  <node id="Read">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <useAdvancedOptions>true</useAdvancedOptions>
      <file>/home/user/Projects/data/product/S2A_MSIL2A_20220812T103031_N0400_R108_T32UMV_20220812T182800.SAFE/MTD_MSIL2A.xml</file>
      <copyMetadata>true</copyMetadata>
      <bandNames>B2,B3,B4,B5,B6,B7</bandNames>
      <pixelRegion>0,0,10980,10980</pixelRegion>
      <maskNames/>
    </parameters>
  </node>
  <node id="Write">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="Read"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>/home/user/Projects/TEMP/S2A_MSIL2A_20220812T103031_N0400_R108_T32UMV_20220812T182800.dim</file>
      <formatName>BEAM-DIMAP</formatName>
    </parameters>
  </node>
  <applicationData id="Presentation">
    <Description/>
    <node id="Read">
      <displayPosition x="115.0" y="92.0"/>
    </node>
    <node id="Write">
      <displayPosition x="348.0" y="100.0"/>
    </node>
  </applicationData>
</graph>

However the moment I switch to Geographic Coordinates…

with the XML looking like this:

<graph id="Graph">
  <version>1.0</version>
  <node id="Read">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <useAdvancedOptions>true</useAdvancedOptions>
      <file>/home/user/Projects/data/product/S2A_MSIL2A_20220812T103031_N0400_R108_T32UMV_20220812T182800.SAFE/MTD_MSIL2A.xml</file>
      <geometryRegion>POLYGON ((7.61434268951416 49.644386291503906, 7.8043413162231445 49.64650344848633, 7.99436092376709 49.648311614990234, 8.18439769744873 49.64980697631836, 8.374448776245117 49.6509895324707, 8.564510345458984 49.651859283447266, 8.7545804977417 49.65241622924805, 8.944653511047363 49.65266418457031, 9.13472843170166 49.6525993347168, 9.135144233703613 49.6525993347168, 9.134803771972656 49.52919387817383, 9.134465217590332 49.40578079223633, 9.134129524230957 49.282371520996094, 9.133795738220215 49.15895462036133, 9.133464813232422 49.03553771972656, 9.133135795593262 48.91211700439453, 9.132808685302734 48.7886962890625, 9.132484436035156 48.6652717590332, 9.13248348236084 48.665000915527344, 9.132076263427734 48.665000915527344, 8.945743560791016 48.665061950683594, 8.759411811828613 48.664825439453125, 8.573083877563477 48.664283752441406, 8.386763572692871 48.66344451904297, 8.20045280456543 48.66230010986328, 8.014155387878418 48.660858154296875, 7.827874660491943 48.65911102294922, 7.641613006591797 48.657066345214844, 7.641605854034424 48.6573371887207, 7.638278484344482 48.78072738647461, 7.6349287033081055 48.904117584228516, 7.631556034088135 49.02750015258789, 7.62816047668457 49.150882720947266, 7.624741554260254 49.27426528930664, 7.621298789978027 49.397640228271484, 7.617832660675049 49.52101516723633, 7.61434268951416 49.644386291503906))</geometryRegion>
      <copyMetadata>true</copyMetadata>
      <bandNames>B2,B3,B4,B5,B6,B7</bandNames>
      <pixelRegion>0,0,10980,10980</pixelRegion>
      <maskNames/>
    </parameters>
  </node>
  <node id="Write">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="Read"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>/home/user/Projects/TEMP/S2A_MSIL2A_20220812T103031_N0400_R108_T32UMV_20220812T182800.dim</file>
      <formatName>BEAM-DIMAP</formatName>
    </parameters>
  </node>
  <applicationData id="Presentation">
    <Description/>
    <node id="Read">
      <displayPosition x="115.0" y="92.0"/>
    </node>
    <node id="Write">
      <displayPosition x="348.0" y="100.0"/>
    </node>
  </applicationData>
</graph>

I would describe the bug as follows:

Selecting Geographic Coordinates in a Read node, adds <geometryRegion/> but does not remove <pixelRegion/>. Going back to Pixel Coordinates does not solve the problem.

The fix should be easy enough (sorry, not familiar with the code base of this NetBeans-inspired application). My guess is that there is a missing “remove this and then add that” part in the code. :slight_smile:

Reproduced! Thanks, I will open a ticket for this, the fix should be easy :slight_smile:
Ticket number SNAP-1584

2 Likes

Since this functionality is otherwise working, it’s only this dialog window that is probably affected. Hope this helps. Thanks for the quick response. I guess for now I will have to edit the XML manually for this and run it only through GPT in the terminal.

Yes, if you use the geographic coordinates, correct manually the xml and run it with gpt. It seems the Graph Builder UI is not well syncronized, leading to this error. Sorry for this.

I also tried switching to Geographic Coordinates inside the Subset node. There is no issue there and I was able to paste the polygon (Geometry to WTK in the mouse context menu of an opened band in the main window). I just wanted to see if the issue occurs somewhere else in case code was re-used. :stuck_out_tongue:

This means that I can use the default Read and then tweak using Subset, which is funny since at the beginning there was a small discussion whether using Subset is worth it in my case. :smiley:

Yes, but advanced read = read +subset (actually only the subset is read, not the entire product), which takes less time than normal Read (entire product) + Subset (2 operators). Well, you can use which options works better for you now :slight_smile:

1 Like

Hi @oana_hogoiu,

I just saw that the ticket regarding this issue is alreaday resolved ([SNAP-1584] - JIRA). However, I still get the same error as @alat while reading a Sentinel-1 product with geographic coordinates. My SNAP version is up to date.

I appreciate any advice. Thank you in advance!

Best,
Kim

Hello,
Yes, the issue is solved, the affected version is SNAP 9.0.4 (what you currently have), and it will be included in the next minor version 9.0.5.

2 Likes

Got it, thank you! :slight_smile: