Skip to content

Instantly share code, notes, and snippets.

@FrieseWoudloper
Created October 26, 2015 13:14
Show Gist options
  • Save FrieseWoudloper/579caa8bfe43675208d2 to your computer and use it in GitHub Desktop.
Save FrieseWoudloper/579caa8bfe43675208d2 to your computer and use it in GitHub Desktop.
# Zie http://stackoverflow.com/questions/14510435/is-there-a-possibility-to-pass-binary-raster-data-directly-to-a-spatial-object
# Optie 1
library(raster)
library(rgdal)
setwd("d:/temp")
url <- "http://geodata.nationaalgeoregister.nl/ahn2/wms?version=1.3.0&service=WMS&request=GetMap&LAYERS=ahn2_05m_int&style=ahn2_05m_detail&WIDTH=1000&HEIGHT=1250&bbox=213089,593892,217076,597981&CRS=EPSG:28992&FORMAT=image/geotiff"
download.file(url, destfile="zoutkamp.tiff", mode = "wb")
map <- brick("zoutkamp.tiff")
plot(map)
# Optie 2
library(png)
library(RCurl)
url <-"http://geodata.nationaalgeoregister.nl/ahn2/wms?version=1.3.0&service=WMS&request=GetMap&LAYERS=ahn2_05m_int&style=ahn2_05m_detail&WIDTH=1000&HEIGHT=1250&bbox=213089,593892,217076,597981&CRS=EPSG:28992&FORMAT=image/png"
png <- getBinaryURL(url)
xx <- readPNG(png)
xx.n <- readPNG(png, info=TRUE)
hoogte <- raster(xx[,,1]) #
plot(map)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment