[gdal-dev] Error with using GML with Python
Even Rouault
even.rouault at spatialys.com
Sun Nov 9 11:27:25 PST 2014
Le dimanche 09 novembre 2014 18:28:13, Pekka Sarkola a écrit :
> Hi,
>
> I might have newbie problem with OGRs GML driver in Python.
>
> I try to read GML files with Python script, but wont get access to
> features. I tried this on Window (ogr version 1.11.1), unfortunately I
> couldnt 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
More information about the gdal-dev
mailing list