Created
January 26, 2015 19:37
-
-
Save kapadia/e6752fecee8b58fd1c32 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
var gdal = require('gdal'); | |
module.exports = {}; | |
module.exports.reproject = reproject; | |
var dstwkt = "PROJCS['WGS 84 / Pseudo-Mercator', GEOGCS['WGS 84', DATUM['WGS_1984', SPHEROID['WGS 84',6378137,298.257223563, AUTHORITY['EPSG','7030']], AUTHORITY['EPSG','6326']], PRIMEM['Greenwich',0], UNIT['degree',0.0174532925199433], AUTHORITY['EPSG','4326']], PROJECTION['Mercator_1SP'], PARAMETER['central_meridian',0], PARAMETER['scale_factor',1], PARAMETER['false_easting',0], PARAMETER['false_northing',0], UNIT['metre',1, AUTHORITY['EPSG','9001']], EXTENSION['PROJ4','+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs'], AUTHORITY['EPSG','3857']]"; | |
var proj4wm = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"; | |
function reproject(srcpath, dstpath, callback) { | |
var src = gdal.open(srcpath); | |
var width = src.rasterSize.x; | |
var height = src.rasterSize.y; | |
var count = src.bands.count(); | |
var driver = src.driver.description; | |
var srcProjection = src.srs; | |
var dstProjection = gdal.SpatialReference.fromProj4(proj4wm); | |
// var dstProjection = new gdal.SpatialReference(dstwkt); | |
var dst = gdal.open(dstpath, mode='w', driver, x_size=width, y_size=height, band_count=count); | |
var opts = { | |
src: src, | |
dst: dst, | |
s_srs: srcProjection, | |
t_srs: dstProjection | |
} | |
gdal.reprojectImage(opts) | |
return callback(null); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment