Last active
August 29, 2015 14:00
-
-
Save onderaltintas/23df47aece4544e93cd0 to your computer and use it in GitHub Desktop.
This file contains 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
--This program is free software: you can redistribute it and/or modify | |
--it under the terms of the GNU General Public License as published by | |
--the Free Software Foundation, either version 3 of the License, or | |
--(at your option) any later version. | |
--This program is distributed in the hope that it will be useful, | |
--but WITHOUT ANY WARRANTY; without even the implied warranty of | |
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
--GNU General Public License for more details. | |
--You should have received a copy of the GNU General Public License | |
--along with this program. If not, see <http://www.gnu.org/licenses/>. | |
--To complete how many pixels required to use as parameter for gdal_grid if calculations will be made on mssql 2008. special -- case after all | |
--Finds distance between 2 points given in EPSG:4326 in meters | |
CREATE PROCEDURE GetDistance | |
@fromPoint geography,@toPoint geography | |
as | |
DECLARE @g geography; | |
DECLARE @h geography; | |
SELECT @fromPoint.STDistance(@toPoint); | |
declare @point1 as geography; | |
declare @point2 as geography; | |
--Finds bounding box 1st and 2nd points to calculate resolution in 1 axis | |
Select @point1=geography::STGeomFromText(boxT.Box.STPointN(3).STAsText(),4326),@point2=geography::STGeomFromText(boxT.Box.STPointN(4).STAsText(),4326) | |
from | |
(select | |
geography::STGeomFromText(geometry::STGeomFromText(geomText,4326).STEnvelope().STAsText(),4326) As Box | |
from quarter q inner join tableNameHere m on q.unifiedId=m.gid where Id = 3519) boxT | |
DECLARE @resolution TABLE (resolution Float) | |
insert @resolution | |
EXECUTE GetDistance @point1,@point2 | |
--Finds raster resolution on 1 axis as it should be 50m=1px | |
Select resolution/50 from @resolution |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment