What a true pain that was! “shonky” (thanks Rory) There just is no proper documentation for Spatial data on MSSQL Server yet. (Oracle is so much simpler for GIS).

Firstly – to get OGR2OGR installed I downloaded the OSGeo4W setup utility which fails with “Unable to get setup.ini from http: //download.osgeo.org/osgeo4w/”.

Eventually I found the trick was to choose “Advanced Install” from the first screen, then “Use IE5 Settings”.

Then – after the local installation had completed – to get it installed on a server without internet connections I copied the entire 2GB folder c:\OSGeo4W\ across the network.

I needed to create a system-variable called “GDAL_DATA” to the path of ‘coordinate_axis.csv’ being “D:\OSGeo4W\share\gdal\”

Lastly, I created a short-cut on my desk-top to cmd.com and customized it so it starts in the ogr2ogr.exe folder.

To import using ogr2ogr.exe … I played with a number of commands in a BAT file until this one worked (all on one line) …

D:\OSGeo4W\bin\ogr2ogr 
-f "MSSQLSpatial" 
"MSSQL:Server=localhost;Database=GIS;trusted_connection=yes" 
"D:\Media\Spatial Data\BFRS_10_MILE.mid" 
-t_srs "EPSG:27700" 
-lco "GEOM_TYPE=geometry" 
-lco "GEOM_NAME=geog27700"

To ‘decode’ that as much as I can …

– Line-1 is the path to ogr2ogr.exe
– Line-2 means import to SQL Server
– Line-3 is the SQL Server connection string (SQL Server 2012 btw)
– Line-4 is the path to the MID file (the MIF file will be imported too)
– Line-5 converts it to ‘Geometry’ projected on the UK template

Advertisements

One response »

  1. Darren Ryhmer says:

    Brilliant! Worked perfectly first time. Thank you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s