[gdal-dev] Error with using GML with Python

Even Rouault even.rouault at spatialys.com
Sun Nov 9 12:45:13 PST 2014


Le dimanche 09 novembre 2014 20:55:09, Pekka Sarkola a écrit :
> Hi Even,
> 
> Thanks about help!
> 
>  Yes, it seems that my python script use older version of GDAL (1.10.1). I
> didn't check that: I thought that even FeatureCount won't work in older
> version.

MTK files are quite close to ""standard"" GML files, so older versions of GDAL 
can open them but will miss some attributes and geometries.
Make sure you delete the .gfs files that may have been generated with GDAL 1.10 
before trying with GDAL 1.11, or you might miss some attributes.

> 
> So I need check how to be sure that right version of ogr is loaded. PATH
> settings etc. boring ;-)
> 
> Rgs,
> 
> Pekka
> 
> ---   Pekka Sarkola  -  pekka.sarkola at gispo.fi  -  www.paikkatieto.com  
> ---
> 
> -----Alkuperäinen viesti-----
> Lähettäjä: Even Rouault [mailto:even.rouault at spatialys.com]
> Lähetetty: 9. marraskuuta 2014 21:27
> Vastaanottaja: gdal-dev at lists.osgeo.org; Pekka.Sarkola at gispo.fi
> Aihe: Re: [gdal-dev] Error with using GML with Python
> 
> Le dimanche 09 novembre 2014 18:28:13, Pekka Sarkola a écrit :
> > Hi,
> > 
> > I might have newbie problem with OGR’s GML driver in Python.
> > 
> > I try to read GML files with Python script, but won’t get access to
> > features. I tried this on Window (ogr version 1.11.1), unfortunately I
> > couldn’t check this in other enviroments, yet.
> > 
> > So my sample testing script result is
> > ---
> > Loop aita layer...
> > 
> >  Count of features: 181
> > 
> > None
> > None
> > Start Loop...
> > End of Loop
> > ---
> > 
> > And sample script is very simple:
> > ---
> > #!/usr/bin/python
> > 
> > # -- Start of test script ---
> > import sys;
> > from osgeo import ogr;
> > 
> > driver = ogr.GetDriverByName('GML');
> > 
> > if driver is None:
> >   print "Error with driver"
> >   sys.exit(1)
> > 
> > fn = '<your path>/L4131R.xml'
> > #fn = '/data/nlsfi/MTK-GML/L34131R.xml'
> > datasrc=driver.Open(fn,0);
> > 
> > if datasrc is None:
> >   print "Error opening " + fn;
> >   sys.exit(1);
> > 
> > print "Loop aita layer..."
> > 
> > myLayer=datasrc.GetLayer("Aita")
> > print " Count of features: "+str(myLayer.GetFeatureCount())
> > 
> > print myLayer.GetNextFeature();
> > 
> > print myLayer.GetFeature(2);
> > 
> > print "Start Loop..."
> > 
> > for feat in myLayer:
> >   print "a"
> > 
> > print "End of Loop"
> > 
> > # -- End of test script ---
> > ---
> > 
> > GML file is National Land Survey of Finland's special GML. I can
> > access with ogrinfo and other command line tools, but not from Python
> > (version 2.7.3). You can download sample datasets from Kapsi, example
> > http://kartat.kapsi.fi/files/maastotietokanta/kaikki/etrs89/gml/L4/L41
> > /
> 
> Pekka,
> 
> I cannot reproduce such a behaviour neither on Linux nor on Windows. Are
> you sure that the GDAL Python bindings you use are GDAL 1.11.1 ?
> 
> Try:
> 
> from osgeo import gdal
> gdal.VersionInfo('')
> 
> You could also try with another datasource, like shapefile, etc.. to see if
> you see a similar issue.
> 
> Even
> 
> > Any help is appreciated. I try to check this also in Ubuntu, but
> > currently I don't have working environment for GDAL 1.11.1. So if
> > somebody can test this on Ubuntu 14.04 (or any other version above
> > 12.04)
> > 
> > Rgs,
> > 
> > Pekka
> > 
> > --
> > Pekka Sarkola
> > Gispo Oy
> > pekka.sarkola at gispo.fi   - GSM +358 40 725 2042
> > www.gispo.fi – www.paikkatieto.com
> > 
> > 
> > _______________________________________________
> > gdal-dev mailing list
> > gdal-dev at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
> --
> Spatialys - Geospatial professional services http://www.spatialys.com

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list