Some Prerequisite Knowledge About Spatial Data

Posted by

SQL Spatial Data Types:

Two kinds of spatial data types:

  • geometry: flat 2D surface with two dimensions. Supposed X = 3 and Y = 4, then our point representation will be like POINT (3 4).
  • geography: uses the same methods but the data type reflects the fact the we live on a curved 2D surface.

However, the two kinds of spatial data types is the need for the aforementioned Spatial Reference IDs (SRID).

SRID:

Both geometry and geography data types have two parts, the coordinates of the object and the SRID number

To check the list of SRID in SQL server, we can execute query statement as belows:

Geography::Point(Latitude,Longitude,SRID); 

The SRID number is set by EPSG standard. It dictates that the SRID of any geometry data is 0 and for Geography the default of SRID is 4326.

An example:

Here is a link of my Github of stored procedure, which aims to get the nearest suburb for each public transport stop:

https://github.com/jacquiwuc/PropertyAnalysis/blob/master/SQ_StationForSuburb.sql

In this stored procedure, it can be seen that

SET @geo1=geography::Point(@stationlat,@stationlong,4326);

Which is an application of transformation of the two spatial data types.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s