[Gdal-dev] GML file problems
Frank Warmerdam
warmerdam at pobox.com
Sat Sep 9 00:34:54 EDT 2006
On 9/8/06, Dan Putler <putler at sauder.ubc.ca> wrote:
> Hi All,
>
> I'm attempting to use ogr2ogr for the purposes of converting a file
> encoded in GML2.1.2 to a shapefile, but ogr2ogr is not recognizing it
> as a GML file. I'm using the version of gdal/ogr bundled with FWTools
> 1.0.5.
>
> Here is the GML file I'm trying to use as a source:
>
> <?xml version="1.0" encoding="utf-8" standalone="no"?>
> <PostalCodeLookup version="1.0.0" xmlns:xsi="http://www.w3.org/2001/
> XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://cgdi-
> dev.geoconnections.org/prototypes/schemas/cgdi/postalcode/1.0.0/
> postalcode.xsd" xmlns:gml="http://www.opengis.net/gml">
> <gml:boundedBy>
> <gml:Null>inapplicable</gml:Null>
> </gml:boundedBy>
> <PostalCodeResultSet sortArea="FSA">
> <PostalCode>
> <gml:name>V1A</gml:name>
> <Placename>Kimberley</Placename>
> <ProvinceOrTerritory>BC</ProvinceOrTerritory>
> <gml:centerOf>
> <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
> <gml:coordinates>-115.970116,49.660305</gml:coordinates>
> </gml:Point>
> </gml:centerOf>
> </PostalCode>
> </PostalCodeResultSet>
> </PostalCodeLookup>
Dan,
I'm embarrassed to admit that the OGR GML reader
is a haphazard hack intended to read GML files without
having to look at the schema files. Because of that, it
uses various giffy rules to try and recognise stuff.
One is that the element that is the parent of a feature
needs to be a gml:featureMember (well actually any
element name ending in Member will do).
Contrast your GML with the style of OGR generated
GML. Note that all the features are kept in a
featureCollection, and that each feature is a child of
a featureMember element.
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/prov.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>2253355.75</gml:X><gml:Y>-76361.7734375</gml:Y></gml:coord>
<gml:coord><gml:X>2747648.5</gml:X><gml:Y>515489.03125</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ogr:province fid="F0">
<ogr:geometryProperty><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2407487.25,512212.40625
2406782.5,513659.375 2407398.0,515030.53125 2410186.75,515489.03125
2411133.5,513513.125 2409505.75,512788.40625
2407487.25,512212.40625</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:AREA>9359132.000</ogr:AREA>
<ogr:PERIMETER>12010.509</ogr:PERIMETER>
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the Gdal-dev
mailing list