I have a very large .gml file with multiple layers in it. I would like to export one of these layers to .shp. It is a polygon layer (of lakes). However, I am getting the error:

ERROR 1: Unrecognised geometry type <Surface>.

The ogr command I was using: ogr2ogr -f "ESRI Shapefile" output.shp input.gml layername

Any thoughts? Is it possible the polygon layer is somehow incorrectly defined as a surface in the GML? Any way I can force it to be a polygon? Or is it something else entirely? I don't often work with .gml, so may be missing something obvious...

EDIT 20101202: Here is a snip of (what appears to be) the relevant info from an example feature in the example file linked below:

        <gml:Surface srsName="EPSG:4140" srsDimension="2">
                               52.2023177 -77.596532 52.2024007 -77.5963559 52.2028141 -77.5962899 52.2028362 -77.5964181 52.2026119 -77.5967049 52.2024106 -77.5967968 52.2023273 -77.5966966 52.2023177 -77.596532

So, the file is identifying it as a 'surface' as well as a 'PolygonPatch'? Perhaps the question should be: what is a 'surface' in a .gml file?

  • What is the output of "ogrinfo input.gml -ro -al"? – geographika Nov 29 '10 at 14:36
  • ogrinfo gives the same "ERROR 1: Unrecognised geometry type <Surface>." – Darren Cope Nov 29 '10 at 15:18
  • Are you using the latest version of GDAL/OGR? gdal.org/ogr/drv_gml.html – geographika Nov 29 '10 at 15:32
  • I am using 1.7.0b2 – Darren Cope Nov 29 '10 at 16:44
  • Can you post a sample of the GML or a link to the file? – DavidF Nov 30 '10 at 15:17

You need to use GDAL 1.8.0 or above to be able to read this kind of GML3 geometry.

| improve this answer | |

Looks like you have GML3 but ogr2ogr is expecting it to be GML2. According to the docs (http://www.gdal.org/ogr/drv_gml.html) only GML 2 or GML 3 Simple Feature is supported, since GML3 SF doesn't support surfaces either I'd say you are out of luck.

I'm also not entirely sure if a shapefile can support surfaces either so I suspect that you are going to run into problems with any solution trying to go this way.

| improve this answer | |
  • The issue is that the feature should be a polygon, according to all of the documentation I can find. It appears that OGR is identifying it incorrectly as a surface when it shouldn't. – Darren Cope Nov 30 '10 at 12:59
  • 1
    It seems more likely that the documentation of your data is wrong than OGR is misreading "polygon" as "surface" but a quick grep of the data file should solve the issue. – Ian Turton Nov 30 '10 at 16:15
  • I have pasted a snippit into the original question. – Darren Cope Dec 2 '10 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.