1 2 Previous Next 23 Replies Latest reply: Nov 26, 2013 9:40 AM by 996581 Go to original post RSS
      • 15. Re: Trying to get multiple cell values within a geometry
        fechen

        Can you post the metadata of your georaster object so I can try to reproduce your problem? To get the metadata, run the following in sqlplus:

         

        set long 10000

        set pagesize 1000

        select t.georaster.metadata from JBA_MEGARASTER_1012 t where id = 1;

         

        Thanks.

        • 16. Re: Trying to get multiple cell values within a geometry
          fechen

          After reading your code, I think the float value reading (ult_raw.substr call) might have some problem. I modified your code a little and ran against the buffer value given in your post (buf = '789C63608002666913066400E2238BC1F8F830BA7E280000C523042B). I don't have any error. Here is the code and result:

           

          set serveroutput on;

           

          DECLARE

          FLT number := 0;

          cdl number;

          vals varchar2(32000) := null;

          VAL number;

          amt integer;

          buf raw(32767);

          MAXV number := null;

          r  raw(8);

          i integer;

           

          BEGIN

            cdl := 32;

            cdl := cdl / 8;

            buf := hextoraw('789C63608002666913066400E2238BC1F8F830BA7E280000C523042B');

            amt := 28;

            i := 1;

            while i < amt loop

               r := utl_raw.substr(buf, i, cdl);

               if cdl = 8 then

                 VAL := UTL_RAW.CAST_TO_BINARY_DOUBLE(R);

               elsif flt = 1 then

                 val := utl_raw.cast_to_binary_float(r);

               else

                 val := utl_raw.cast_to_binary_integer(r);

               end if;

           

           

               if MAXV is null or MAXV < VAL then

                 MAXV := VAL;

               end if;

           

               IF i = 1 THEN

                 VALS := VALS || VAL;

               ELSE

                 VALS := VALS ||'|'|| VAL;

               END IF;

           

               i := i+cdl;

           

            end loop;

           

            dbms_output.put_line(VALS);

            dbms_output.put_line('Max value: ' || maxv);

           

          END;

          /

          show errors;

           

           

          2023514976|-2147326359|319185920|-500986943|-117952326|2116550656|-987560917

          Max value: 2116550656

           

          You mentioned that the 7 values you got from getRasterSubset is not correct. That doesn't look right to me either. Could you print out the win2 value after calling the getRasterSubset? Also please print out the metadata as I instructed in the previous post. Thanks.

          • 17. Re: Trying to get multiple cell values within a geometry
            996581

            No problem,

             

            WIN2 = '161148,76364,161152,76368'

             

            The metadata =

            <georasterMetadata xmlns="http://xmlns.oracle.com/spatial/georaster">

              <objectInfo>

                <rasterType>20001</rasterType>

                <isBlank>false</isBlank>

                <defaultRed>1</defaultRed>

                <defaultGreen>1</defaultGreen>

                <defaultBlue>1</defaultBlue>

              </objectInfo>

              <rasterInfo>

                <cellRepresentation>UNDEFINED</cellRepresentation>

                <cellDepth>32BIT_S</cellDepth>

                <totalDimensions>2</totalDimensions>

                <dimensionSize type="ROW">

                  <size>212759</size>

                </dimensionSize>

                <dimensionSize type="COLUMN">

                  <size>112861</size>

                </dimensionSize>

                <ULTCoordinate>

                  <row>0</row>

                  <column>0</column>

                </ULTCoordinate>

                <blocking>

                  <type>REGULAR</type>

                  <totalRowBlocks>416</totalRowBlocks>

                  <totalColumnBlocks>221</totalColumnBlocks>

                  <rowBlockSize>512</rowBlockSize>

                  <columnBlockSize>512</columnBlockSize>

                </blocking>

                <interleaving>BIP</interleaving>

                <pyramid>

                  <type>NONE</type>

                </pyramid>

                <compression>

                  <type>DEFLATE</type>

                </compression>

              </rasterInfo>

              <spatialReferenceInfo>

                <isReferenced>true</isReferenced>

                <isRectified>true</isRectified>

                <SRID>27700</SRID>

                <spatialResolution dimensionType="X">

                  <resolution>5</resolution>

                </spatialResolution>

                <spatialResolution dimensionType="Y">

                  <resolution>5</resolution>

                </spatialResolution>

                <modelCoordinateLocation>CENTER</modelCoordinateLocation>

                <modelType>FunctionalFitting</modelType>

                <polynomialModel rowOff="0" columnOff="0" xOff="0" yOff="0" zOff="0" rowScale="1" columnScale="1" xScale="1" yScale="1" zScale="1">

                  <pPolynomial pType="1" nVars="2" order="1" nCoefficients="3">

                    <polynomialCoefficients>195880.5 -0 -0.2</polynomialCoefficients>

                  </pPolynomial>

                  <qPolynomial pType="1" nVars="0" order="0" nCoefficients="1">

                    <polynomialCoefficients>1</polynomialCoefficients>

                  </qPolynomial>

                  <rPolynomial pType="1" nVars="2" order="1" nCoefficients="3">

                    <polynomialCoefficients>-18337.5 0.2 -0</polynomialCoefficients>

                  </rPolynomial>

                  <sPolynomial pType="1" nVars="0" order="0" nCoefficients="1">

                    <polynomialCoefficients>1</polynomialCoefficients>

                  </sPolynomial>

                </polynomialModel>

              </spatialReferenceInfo>

              <layerInfo>

                <layerDimension>BAND</layerDimension>

                <objectLayer>

                  <layerNumber>0</layerNumber>

                  <layerDimensionOrdinate>0</layerDimensionOrdinate>

                  <layerID/>

                  <NODATA>

                    <value>2147483647</value>

                  </NODATA>

                </objectLayer>

              </layerInfo>

            </georasterMetadata>

            • 18. Re: Trying to get multiple cell values within a geometry
              996581

              Hey zzhang, sorry, I didnt spot this at the end of page 1.

               

              Thanks again (to everyone helping) for all this help, it is much appreciated, I wasn't getting anywhere on my own.

               

              r4

               

              r4 is the variable I use to store the utl_raw.substr from the "buf" varchar2 which is basically the blob returned from getRasterSubSet.

               

              When I define it as "r4 raw(4);" I get an error saying it is not big enough to store the result of utl_raw.substr, which I am taking in 4 byte chunks (so why isnt it big enough).

               

              If I define it as "r4 raw(5);", it is fine.

               

              Compression

               

              The source compression is "DEFLATE", I tried adding 'compression=NONE' as the storageParam argument, but I got all zeros.

               

              What do you think?

              • 19. Re: Trying to get multiple cell values within a geometry
                996581

                Also,

                 

                When I add compression=NONE to the getrastersubset function the buffer line I get back is:

                 

                000000000000000000031B3400000000000000000000000000031B3400031B34000000000000000000031B3400031B3400031B3400031B3400031B3400031B3400031B3400031B3400031B3400000000000000000000000000031B340000000000000000

                • 20. Re: Trying to get multiple cell values within a geometry
                  fechen

                  The reason you have to use "r4 raw(5)" is because you have " r4 := utl_raw.substr(buf, (i-1)*cdl+1, cdl+1);" where substr gets data of length (cdl+1) which is 5. If you use "r4 := utl_raw.substr(buf, (i-1)*cdl+1, cdl);", you should be fine. The code I post earlier is even simpler. 

                  • 21. Re: Trying to get multiple cell values within a geometry
                    996581

                    I think that was the bug, now I'm getting the value I expect!

                     

                    I'm going to do more tests, but that is looking pretty good!

                    • 22. Re: Trying to get multiple cell values within a geometry
                      fechen

                      Ensure the storageParameter has "compression=NONE" and is passed into the getRasterSubset function call. When the length of the lob  is obtained from "len := dbms_lob.getlength(lb);", please check if len == ROW_COUNT * COL_COUNT * cdl, (cdl is the cell depth in bytes). They should be equal after "compression=NONE" option. For example, for WIN2 = '161148,76364,161152,76368', the len should be 64 bytes. The 28 bytes buffer posted earlier could be  the compressed data returned by getRasterSubset.

                      • 23. Re: Trying to get multiple cell values within a geometry
                        996581

                        That's right the compressed response was 28, but the uncompressed was 100, I thought there was a problem with the compression, because when I set compression=NONE I got all zeros, but when I fixed the substr length, it started working fine.

                         

                        I ran a few other tests and everything looks good, I think I've finally got this one working.

                         

                        I will rewrite my code to be more straight forward and then I'll post it so people can see what the final version looks like.

                         

                        Thanks again everyone for all your help!

                        1 2 Previous Next