Posts Tagged ‘sql server


SQL Server Spatial in ArcMap 10

In my last post, I showed how to load geospatial data into SQL Server.  I want to continue that post with how to show that data in ArcMap 10. 

We are going to use that same data to render it in ArcMap.

  1. In the File menu, choose Add Data > Add Query Layer.
  2. In the New Query Layer dialog box, click Connections.
  3. In the Manage Connection(s) dialog box, click New.
  4. In the Database Connection dialog box:
    1. For DBMS Client choose sqlserver
    2. For Data Source, enter you SQL Server (i.e. HOGWARTS\SQLEXPRESS)
    3. For Data Base, enter the database name (i.e. WORLD)
    4. For Authentication, choose OS Authentication.
    5. Click OK.
  5. In the Manage Connection(s) dialog box, click OK.
  6. In the New Query Layer dialog box, double click the table that contains the spatial data.
  7. For Name enter the of the query (i.e. Major Highways)
  8. Click Finish.

Unfortunately, this is READ ONLY.  If you want to see how to EDIT this data, stay tuned for the next Post.


Two Free Ways to Push Geographic Data in SQL Server

If you own SQL Server 2008 or higher (even the free Express version) you have the essentials of a GIS. 

But how to put GIS data into SQL Server?  I cover 2 simple ways to get data into SQL Server:

  1. SharpGIS’s SQL Server Spatial Tools
  2. OGR2OGR as part of the GDAL Suite at

If you downloads SharpGIS’s tool, you can load a ShapeFile (actually it is series of files such as Road.shp, Road.dbf, Road.idx..) into SQL Server.

 SharpGIS's Shapefile Uploader

In the Configure Dialog dialog box, you need to log into SQL Server, enter the SQL Server name and choose the database.

ShareGIS Shapefile Uploader Configure

If you shapefile has a coordinate system that is projected, such as State Plane or UTM, you should use the Geometry, otherwise choose Geography (Latitude and Longitude).

Also, I recommend not to create the Spatial Index right away as I find this often causes errors during load with this tool.

Leave the default Table Name, Geometry Name and Key Name and click Upload to Database.

To view the data, open the Microsoft SQL Server Management Studio and expand the Databases to your current database.

Right-click On your Table and choose Select Top 1000 Rows to see the SHP you just loaded.

Now, to load the same SHP File, you will have to use the Command Prompt with the OGR2OGR Tool.

To create a BAT or batch file, simply create a text file and save it with a .bat extension.

In the *.bat file, first add the path of the OGR2OGR.exe:

“C:\Program Files\GDAL\ogr2ogr.exe”

Then add the -f MSSQLSpatial switch to import into SQL Server.

Next, add the connection to SQL Server:

Finally, add the path of where the Shapefile is:

Full entry:
“C:\Program Files\GDAL\ogr2ogr.exe” -f MSSQLSpatial  “MSSQL:server=HOGWARTS\SQLEXPRESS;database=WORLD;trusted_connection=yes”  D:\Projects\DMTI\SHP\RAIL75.shp

Finally, double-click on the ogr.bat file or whatever you named it, and the SHP file will be loaded into SQL Server.

To view the data, open the Microsoft SQL Server Management Studio and expand the Databases to your current database.

The additional dbo.geometry_columns and dbo.spatial_ref_sys are used by Open Source GISs such as QGIS to determine the spatial data columns and their coordinate system.  QGIS can render the data without these support tables however, so they are not required.


DWG to FDO: Moving Blocks to SDF (with Attributes)

I have had a lot of questions lately on how to move complex DWG files with Rotated Blocks with Attributes to FDO.

(Feature Data Objects include storage such as Oracle Spatial, SQL Server Spatial, SHP, SDF, mySQL, etc.)

Moving from DWG to Universal Spatial Storage (USS) is key for any organization wanting to share data or maintain a “Truth” to their assets.

I have created a video that shows how to take Blocks with 3 Attributes and export them to a SDF file – which can then be put in the SQL Server or Oracle etc.

I use the existing block as a symbol with FDO, so please keep your individual DWG block libraries on your system.  For example, I have a folder with all my utility blocks – each block exploded in an individual DWG file.

Gordon Luckett

Arrow Geomatics Inc's Gordon Luckett


gordon dot luckett at arrowgeo dot com 1-519-837-9500 (Arrow Geomatics Inc.)

Checkout MapGuide Guy’s Youtube Channel