Hi Frank:<br>Thanks very much for your reply. <br>About GML files, actually, I grab The GML files from OpenLayers.org. <br>as you know OpenLayers can read GML files directly. <br>The GML which i used is located at <a href="http://www.openlayers.org/dev/examples/gml/multipolygon.xml">http://www.openlayers.org/dev/examples/gml/multipolygon.xml</a><br>
You have to change xml to gml by yourself. <br>The commend which I used for converting is that <br>&gt; ogr2ogr -f &quot;ESRI Shapefile&quot; polygon.shp multipolygon.gml<br>the above commend will create few shp files, so I have also tried another one <br>
&gt; ogr2ogr -f &quot;ESRI Shapefile&quot; polygon.shp multipolygon.gml multipolygon<br>this one will create one shapefile. <br>but the polygon.shp file does not contain the first feature&#39;s and the third feature&#39;s attribute<br>
<br>I think the vec_tr.py is very helpful to me, espeically, WalkandTransform function. <br>I would contact you when I have some results. <br><br>All the best <br><br>Xiaoyu<br><br><br><br><div class="gmail_quote">On Wed, Dec 17, 2008 at 6:38 PM, Frank Warmerdam <span dir="ltr">&lt;<a href="mailto:warmerdam@pobox.com">warmerdam@pobox.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">Xiaoyu Guan wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Dear All:<br>
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.<br>

Is possbile that somebody give me some hints? for example how many steps to slove the problems? what is the data flow?<br>
</blockquote>
<br></div>
Xiaoyu,<br>
<br>
It might be helpful if you provided a sample GML file you would like to<br>
translate and explained the problem you encountered using ogr2ogr.<br>
<br>
If you use the Python bindings for OGR to read the GML file it is<br>
possible you will see similar problems to ogr2ogr since the data<br>
access mechanism is the same. &nbsp;The OGR GML driver certainly has many<br>
problems with sophisticated GML.<br>
<br>
I think the following script should give an idea how to read data<br>
from one OGR datasource, and write it to another. &nbsp;The script is<br>
also intended to provide a hook function to apply transformations to<br>
the coordinates though I don&#39;t think you will need this aspect.<br>
<br>
 &nbsp;<a href="http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/vec_tr.py" target="_blank">http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/vec_tr.py</a><br>
<br>
Best regards,<br><font color="#888888">
-- <br>
---------------------------------------+--------------------------------------<br>
I set the clouds in motion - turn up &nbsp; | Frank Warmerdam, <a href="mailto:warmerdam@pobox.com" target="_blank">warmerdam@pobox.com</a><br>
light and sound - activate the windows | <a href="http://pobox.com/%7Ewarmerdam" target="_blank">http://pobox.com/~warmerdam</a><br>
and watch the world go round - Rush &nbsp; &nbsp;| Geospatial Programmer for Rent<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Xiaoyu Guan (Sam)<br><a href="http://guanxiaoyu.net">http://guanxiaoyu.net</a><br><br>