Skip to content

Instantly share code, notes, and snippets.

@prl900
Created May 3, 2018 00:28
Show Gist options
  • Save prl900/adc64bca216942374be5e885fa9e0277 to your computer and use it in GitHub Desktop.
Save prl900/adc64bca216942374be5e885fa9e0277 to your computer and use it in GitHub Desktop.
Testing remote access to COG files hosted on AWS S3
package main
import (
"github.com/terrascope/gocog"
"fmt"
"image"
"image/png"
"net/http"
"os"
)
func main() {
deaS3 := "http://dea-public-data.s3-ap-southeast-2.amazonaws.com/S2_MSI_ARD/05S135E-10S140E/S2A_OPER_MSI_ARD_TL_EPA__20170525T110033_A002330_T54LUP_N02.04/NBAR/S2A_OPER_MSI_ARD_TL_EPA__20170525T110033_A002330_T54LUP_NBAR_B01.TIF"
resp, err := http.Get(deaS3)
if err != nil {
fmt.Println("url not found!", err)
return
}
defer resp.Body.Close()
img, err := gocog.DecodeLevelSubImage(resp.Body, 0, image.Rect(1000, 1000, 1900, 1900))
if err != nil {
fmt.Println("error reading file!", err)
return
}
fmt.Println(img.Bounds())
myfile, _ := os.Create("test.png")
png.Encode(myfile, img)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment