[gdal-dev] help! convert GML to Shp by using python

Frank Warmerdam warmerdam at pobox.com
Wed Dec 17 12:38:57 EST 2008


Xiaoyu Guan wrote:
> Dear All:
> I would like to use GDAL/OGR library for converting GML files to Shp 
> files. I have look around on internet. there are a lot of people use 
> OGR2OGR convert them. I have already try use ogr2ogr , convert gml to 
> shp. unfornately, the result is not what I expected. for example. I 
> convert one ploygon file, there are few attributes lost. So I would like 
> to know how to write a python script to done the job.
> Is possbile that somebody give me some hints? for example how many steps 
> to slove the problems? what is the data flow?

Xiaoyu,

It might be helpful if you provided a sample GML file you would like to
translate and explained the problem you encountered using ogr2ogr.

If you use the Python bindings for OGR to read the GML file it is
possible you will see similar problems to ogr2ogr since the data
access mechanism is the same.  The OGR GML driver certainly has many
problems with sophisticated GML.

I think the following script should give an idea how to read data
from one OGR datasource, and write it to another.  The script is
also intended to provide a hook function to apply transformations to
the coordinates though I don't think you will need this aspect.

   http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/vec_tr.py

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