Site menu:


Site search

OGR 1.8 – SQL Spatial and GML 3 Support!

I spent my morning today playing with some of the new data formats in OGR 1.8 (see the release notes for more info).

I’ve had a massive (44.2 GB) GML 3 file sitting around for a while that I’ve had plans for. Unfortunately, until now nothing would even touch a GML 3 file that big. With the release of OGR 1.8, I can now read the file, and also dump it to other OGR supported formats. Of course, the problem was that the output is much too large to go to a shapefile, or any other similar file-based format! Luckily, OGR 1.8 also now supports SQL Spatial!  Thus, I’m currently working on chunking the data from GML 3 into SQL Spatial.

All the documentation is out there, but just so you don’t have to jump around to find it, here is the command I ended up using (on a small sample…the big boy will come later!) Again, you must be using OGR 1.8 for this to work!

ogr2ogr -overwrite -f “MSSQLSpatial” “MSSQL:server=;database=OGR_Test;trusted_connection=yes” “C:\Users\dcope\Desktop\small test\033c04_6_0.gml” HD_1480009_2

Basically, it’s a standard ogr2ogr command, with the output format (-f) set to SQL Spatial, and the database connection parameters set. I struggled for a while to get it to work…the key was entering the IP without \\ in front (e.g. rather than \\ The path to the input file is then given (stick it in quotes if there are spaces in the path, or just do it all the time as good practice) and then the layer name from the GML file is specified if you want only a specific layer converted. If you don’t specify a layer name, a table for each layer in the GML file will be created in the database.



Comment from Guillaume
Time April 4, 2011 at 5:49 am

Good to know. I will test it. Only few solutions exists to loads coverage to SQL SERVER spatial, I have tried shape2sql which works but cannot automize several translation!

Comment from Hoang
Time September 13, 2011 at 2:31 pm

Good article. Have you tried to generate gml 3 from spatial database? If so, can you share it since I can only get the gml 2 using the ogr 1.8?

Thanks – H

Comment from darrencope
Time September 13, 2011 at 7:11 pm

Hi Hoang,

No, I have yet to try that; sorry! Let us know if you have any luck.

Comment from Hoang
Time September 14, 2011 at 8:15 am


I found the option, example for using Oracle:
ogr2ogr -f GML test.gml OCI:name/passwd@database_instance:table -dsco FORMAT=GML3

I haven’t tried with SQL Spatial yet, but it should look like:

ogr2ogr -f GML test.gml “MSSQL:server=server_name;database=dbname;trusted_connection=yes” -dsco FORMAT=GML3

Write a comment