[gdal-dev] ogr2ogr problem converting UK Ordnance Survey MasterMap
Even Rouault
even.rouault at mines-paris.org
Wed Jun 30 14:53:38 EDT 2010
Jez,
the reason for the orientation field to be recognize in the CartographicSymbol
layer and not in the CartographicText layer lies in the structure of the GML
file and limitations of the OGR GML driver and/or OGR data model.
Namely OGR only supports a "flat" organization of fields whereas GML (being
XML based) supports a tree-like organization. In the CartographicSymbol
layer, the orientation element is at the first level, whereas in the
CartographicText, it is included inside the <textRendering> element, and then
is ignored (see below examples)
<osgb:CartographicSymbol fid='osgb1000000729439973'>
<osgb:featureCode>10165</osgb:featureCode>
<osgb:version>1</osgb:version>
<osgb:versionDate>2001-11-11</osgb:versionDate>
<osgb:theme>Rail</osgb:theme>
<osgb:changeHistory>
<osgb:changeDate>2001-03-12</osgb:changeDate>
<osgb:reasonForChange>New</osgb:reasonForChange>
</osgb:changeHistory>
<osgb:descriptiveGroup>Rail</osgb:descriptiveGroup>
<osgb:descriptiveTerm>Switch</osgb:descriptiveTerm>
<osgb:orientation>3009</osgb:orientation>
<osgb:physicalLevel>50</osgb:physicalLevel>
<osgb:point>
<gml:Point srsName='osgb:BNG'>
<gml:coordinates>291781.470,92943.570</gml:coordinates>
</gml:Point>
</osgb:point>
</osgb:CartographicSymbol>
<osgb:CartographicText fid='osgb1000000729439996'>
<osgb:featureCode>10026</osgb:featureCode>
<osgb:version>1</osgb:version>
<osgb:versionDate>2001-11-11</osgb:versionDate>
<osgb:theme>Buildings</osgb:theme>
<osgb:anchorPoint>
<gml:Point srsName='osgb:BNG'>
<gml:coordinates>291636.850,92668.150</gml:coordinates>
</gml:Point>
</osgb:anchorPoint>
<osgb:changeHistory>
<osgb:changeDate>1987-12-01</osgb:changeDate>
<osgb:reasonForChange>New</osgb:reasonForChange>
</osgb:changeHistory>
<osgb:descriptiveGroup>Buildings Or Structure</osgb:descriptiveGroup>
<osgb:make>Manmade</osgb:make>
<osgb:physicalLevel>50</osgb:physicalLevel>
<osgb:textRendering>
<osgb:anchorPosition>3</osgb:anchorPosition>
<osgb:font>2</osgb:font>
<osgb:height>1.500</osgb:height>
<osgb:orientation>545</osgb:orientation>
</osgb:textRendering>
<osgb:textString>44</osgb:textString>
</osgb:CartographicText>
We could imagine an enhancement of the GML driver to try to "flatten" the
attributes. For example to return textRendering_anchorPosition,
textRendering_font, .... But it doesn't look trivial to add.
To workaround this, you can open the GML with your favorite text editor (or
sed ;-)) and replace <osgb:textRendering> and </osgb:textRendering> by
nothing
This works nicely ;-)
Best regards,
Even
Le Wednesday 30 June 2010 17:17:12 Jez Walters, vous avez écrit :
> Frank,
>
>
> Thanks for looking in to this! I've just repeated the problem with the
> Ordnance Survey sample MasterMap, which is available from here:
>
> http://www.ordnancesurvey.co.uk/oswebsite/products/innovations/sampledata/O
>SMasterMap_Topo/58116-SX9192-2c1.gz
>
> I tried converting the above GML to ESRI shapefile using the following
> command:
>
> ogr2ogr SX9192 58116-SX9192-2c1
>
> One thing I've noticed is that the schema referenced in the GML
> (http://www.ordnancesurvey.co.uk/xml/schema/v7/OSDNFFeatures.xsd) defines a
> number of elements called "complexType". The "complexType" element with a
> name of "CartographicTextType" is defined like this:
>
> <complexType name="CartographicTextType">
> <complexContent>
> <extension base="osgb:AbstractFeatureType">
> <sequence>
> <element name="anchorPoint" type="gml:PointPropertyType"/>
> <element name="changeHistory" type="osgb:changeHistoryType"
> maxOccurs="unbounded"/> <element name="descriptiveGroup"
> type="osgb:descriptiveGroupType" minOccurs="0" maxOccurs="unbounded"/>
> <element name="descriptiveTerm" type="string" minOccurs="0"
> maxOccurs="unbounded"/> <element name="make" type="osgb:makeType"
> minOccurs="0"/>
> <element name="physicalLevel" type="osgb:physicalLevelType"/>
> <element name="physicalPresence" type="osgb:physicalPresenceType"
> minOccurs="0"/> <element name="textRendering"
> type="osgb:textRenderingType"/>
> <element name="textString" type="string"/>
> </sequence>
> </extension>
> </complexContent>
> </complexType>
>
> >From which I conclude that the orientation is actually part of the
> > "textRendering" element. I'm sure I'm on to something with this, but I'm
> > not sure how to proceed from here!
>
> Warm regards,
>
>
> Jez
>
>
> -----Original Message-----
> From: fwarmerdam at gmail.com [mailto:fwarmerdam at gmail.com] On Behalf Of Frank
> Warmerdam Sent: Wednesday 30 June 2010 15:38
> To: Jez Walters
> Cc: gdal-dev at lists.osgeo.org
> Subject: Re: [gdal-dev] ogr2ogr problem converting UK Ordnance Survey
> MasterMap
>
> Jez,
>
> Can you provide a mastermap file I can test with?
>
> Best regards,
>
> On Wed, Jun 30, 2010 at 4:31 PM, Jez Walters <jez.walters at ipl.com> wrote:
> > Not quite sure if I've got the right forum, but I'm having trouble using
> > the 'ogr2ogr' utility (part of GDAL 1.7.2) to convert Ordnance Survey GML
> > into ESRI shapefiles.
> >
> > The 'orientation' field is being ignored when I convert the
> > CartographicText layer, although this field gets successfully translated
> > for the
> > CartographicSymbol layer. All the other CartographicText layer fields
> > appear just fine in the generated '.dbf' file.
> >
> > Is there a way of forcing ogr2ogr to recognise the orientation field?
> > Can anyone suggest an alternative Open Source conversion utility? I'm
> > fairly new to GIS systems, so I might be making an obvious mistake, but
> > any advice is very gratefully received! :-)
> > --
> > View this message in context:
> > http://osgeo-org.1803224.n2.nabble.com/ogr2ogr-problem-converting-UK-Ordn
> >ance-Survey-MasterMap-tp5237796p5237796.html Sent from the GDAL - Dev
> > mailing list archive at Nabble.com.
> > _______________________________________________
> > gdal-dev mailing list
> > gdal-dev at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/gdal-dev
More information about the gdal-dev
mailing list