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

Frank Warmerdam warmerdam at pobox.com
Thu Dec 18 11:52:32 EST 2008


Xiaoyu Guan wrote:
> Hi Frank:
> Thanks very much for your reply.
> About GML files, actually, I grab The GML files from OpenLayers.org.
> as you know OpenLayers can read GML files directly.
> The GML which i used is located at 
> http://www.openlayers.org/dev/examples/gml/multipolygon.xml
> You have to change xml to gml by yourself.
> The commend which I used for converting is that
>  > ogr2ogr -f "ESRI Shapefile" polygon.shp multipolygon.gml
> the above commend will create few shp files, so I have also tried 
> another one
>  > ogr2ogr -f "ESRI Shapefile" polygon.shp multipolygon.gml multipolygon
> this one will create one shapefile.
> but the polygon.shp file does not contain the first feature's and the 
> third feature's attribute

Xiaoyu,

I tried a translation like:

  ogr2ogr out.shp multipolygon.xml

and this seemed to produce a shapefile with all three features, and all
their attributes (ogc_fid, name, id).  I did this with GDAL/OGR trunk -
essentially identical to 1.6.0.

I observe that this gml file is produced by MapServer, and there should
be no need to rename it with a .gml extension.

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