Jump to content
Sign in to follow this  
dummzeuch

convert embedded GML to a world file

Recommended Posts

I've got picutres (airial photos) in jpeg2000 format (filename.jp2) with embedded GML (Geographic Markup Language) information giving their geographic position.

 

I need to use this with a tool that can only handle JPEG files with additional world files (filename.jpg + filename.jpw).

 

I already have got a conversion tool for jpeg2000 to jpeg (Yes, I know that jpeg2000 is lossless while jpeg isn't, but that doesn't matter in this context.) but it does not handle the gml information.

 

I need to do two things;

  1. extract the GML text
  2. interpret this text in the same way as a world file

Eventually this should result in a program that reads those .jp2 files and generates .jpw files for each of them.

 

Before I reinvent the wheel: Is there already a tool that can do that (in batch mode!)?

 

If not:

Extracting the GML can be done by simply parsing the start of the file until it encounters the matching strings. Not elegant but it would work. I'd prefer a library that can do this according to specification though.

 

I tried to understand the GML specification, but so far failed. It's very complex and apparently can do a lot more than I need. A world file contains 6 lines of text:

 

  • Line 1: A: pixel size in the x-direction in map units/pixel
  • Line 2: D: rotation about y-axis
  • Line 3: B: rotation about x-axis
  • Line 4: E: pixel size in the y-direction in map units, almost always negative[3]
  • Line 5: C: x-coordinate of the center of the upper left pixel
  • Line 6: F: y-coordinate of the center of the upper left pixel

 

I'm not sure how to get this from the GML information:

<gml:FeatureCollection
   xmlns:gml="http://www.opengis.net/gml"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/profiles/gmlJP2Profile/1.0.0/gmlJP2Profile.xsd">
  <gml:boundedBy>
    <gml:Envelope srsName="urn:ogc:def:crs:EPSG::25832">
      <gml:lowerCorner>319000 5629000</gml:lowerCorner>
      <gml:upperCorner>320000 5630000</gml:upperCorner>
    </gml:Envelope>
  </gml:boundedBy>
  <gml:featureMember>
    <gml:FeatureCollection>
      <gml:featureMember>
        <gml:RectifiedGridCoverage dimension="2" gml:id="RGC0001">
          <gml:rectifiedGridDomain>
            <gml:RectifiedGrid dimension="2">
              <gml:limits>
                <gml:GridEnvelope>
                  <gml:low>0 0</gml:low>
                  <gml:high>9999 9999</gml:high>
                </gml:GridEnvelope>
              </gml:limits>
              <gml:axisName>x</gml:axisName>
              <gml:axisName>y</gml:axisName>
              <gml:origin>
                <gml:Point gml:id="P0001" srsName="urn:ogc:def:crs:EPSG::25832">
                  <gml:pos>319000.05 5629999.95</gml:pos>
                </gml:Point>
              </gml:origin>
              <gml:offsetVector srsName="urn:ogc:def:crs:EPSG::25832">0.1 0</gml:offsetVector>
              <gml:offsetVector srsName="urn:ogc:def:crs:EPSG::25832">0 -0.1</gml:offsetVector>
            </gml:RectifiedGrid>
          </gml:rectifiedGridDomain>
          <gml:rangeSet>
            <gml:File>
              <gml:rangeParameters/>
              <gml:fileName>gmljp2://codestream/0</gml:fileName>
              <gml:fileStructure>Record Interleaved</gml:fileStructure>
            </gml:File>
          </gml:rangeSet>
        </gml:RectifiedGridCoverage>
      </gml:featureMember>
    </gml:FeatureCollection>
  </gml:featureMember>
</gml:FeatureCollection>

gml:lowerCorner and gml:upperConer seem to be the coordinates of the top left and bottom right of the picture in UTM zone 32N, that should take care of lines 5 and 6 of the world file. Pixels sizes don't seem to be part of the data. I could probably assume a rotation of  for these kinds of pictures. So maybe I could simply compute the pixels sizes from the picture size and the given coordinates?

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×