Monday, January 26, 2015

How to import Spatial Data to SQL Server


   Spatial data functions are great but first we need to find some real spatial data to try them. We need to find maps first. You can download free maps from http://www.census.gov/geo/maps-data/data/tiger.html
Census Bureau has all kind of free maps on their website, Let's start with a simple download.
You can download the states from this page.
File should be in Zip format, and when you extract it you will see bunch of shape files.
What is a shape file?
A shapefile is a simple, nontopological format for storing the geometric location and attribute information of geographic features. Geographic features in a shapefile can be represented by points, lines, or polygons (areas).

We can't upload shape files to Sql server manually. We need to download Shape2SQL application.
It's a great and free tool to upload any shape file to SQL environment.


  • Find the shapefiles you just downloaded from the Census Bureau.
  • Configure your sql server settings by clicking on Configure
  • Check the Set SRID checkbox.
  • Give a name to your new table
  • Click on Upload to Database to start uploading.
When it's over, you should be able to see the Table in your Sql Server database.
Now if you will write a simple sql query for your new table.If the returned results contains any Spatial Data you should be able to see a new tab right beside the Results tab in SSMS.


If you click on the Spatial Results tab, you should be able to see the results. You can change the labels by State label column drop down.

I will talk about Spatial data functions in my next posts.


5 comments:

  1. hi Hsavran,
    I'm indika and from Microsoft
    could you please let me know your contact details , i need your help to build some app

    regards,
    Indika

    ReplyDelete
    Replies
    1. Sure Indika, you can reach me from the LinkedIn. https://www.linkedin.com/in/hasansavran/

      Delete
    2. i send a request , lease accespt , need some help on esisir map

      Delete
  2. Dear hsavran,

    Can you please show How to import Spatial raster(images) Data to SQL Server

    ReplyDelete
  3. how to export data from SQL Server into .shp file.

    ReplyDelete