Created
June 25, 2013 22:25
-
-
Save caseywatson/5863028 to your computer and use it in GitHub Desktop.
This code will generate random points given a min and max ID, min and max X coordinate and min and max Y coordinate using SQL geospatial data types.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DECLARE @min BIGINT = 9989 | |
| DECLARE @max BIGINT = 21899 | |
| DECLARE @minX FLOAT = -118.3876873 | |
| DECLARE @maxX FLOAT = -87.55091344 | |
| DECLARE @minY FLOAT = 30.195573 | |
| DECLARE @maxY FLOAT = 42.010291 | |
| WHILE (@min < @max) BEGIN | |
| SET @min = (@min + 1) | |
| INSERT INTO [DRN].[ScanLocation] | |
| (ScanID, ScanGeo) | |
| VALUES (@min, 'POINT(' + cast((((@maxX - @minX) * RAND()) + @minX) as NVARCHAR(15)) + ' ' + cast((((@maxY - @minY) * RAND()) + @minY) as NVARCHAR(15)) + ')') | |
| END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment