[R-sig-Geo] Rgdal GeoTIFF
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Thu Dec 16 16:20:58 CET 2010
Browsing through your script, another issue I noted is that you
interpolate in long/lat, but the software assumes Euclidian distances
make sense as a distance measure in this space. They don't.
Wbr,
On 12/16/2010 03:52 PM, Tarek Benamara wrote:
> Hallo,
>
> I have used rgdal to generate a GeoTIFF for my krige Interpolation but the
> output image is a 2 Band image und without RGB Color, my Question is haw to
> give the RGB Color to my GeoTFF and how to increase resolution with rgdal.
>
> And this is my R-File
>
>
>
>
> ## load some libraries first:
>
> library(gstat)
>
> library(RODBC)
>
> library(rgdal)
>
> library(grid)
>
> library(intamap)
>
> ## load data
>
> channel <- odbcConnect("postgis", "postgres", "postgres")
>
> table = sqlQuery(channel, "SELECT max(stat.gid) as oid,max(stat.the_geom) as
> the_geom,max(stat.station_latitude_d) as lat,max(stat.station_longitude_d)
> as lon,max(stick.wert) as wert FROM luft_messstationen_meta as
> stat,stickstoffdioxid as stick WHERE stat.gid=stick.station_id AND
> date='2010-11-20' group by stat.gid order by oid;")
>
> ## gstat does not like missing data, subset original data:
>
> e <- na.omit(table)
>
>
> coordinates(e) <- ~ lon+lat
>
>
>
> ## create a grid onto which we will interpolate:
>
> ## first get the range in data
>
> x.range <- range(e at coords[,1])
>
> y.range <- range(e at coords[,2])
>
> ## now expand to a grid with 500 meter spacing:
>
> grd <- expand.grid(x=seq(from=x.range[1], to=x.range[2], by=0.05),
> y=seq(from=y.range[1], to=y.range[2], by=0.05) )
>
>
> ## convert to SpatialPixel class
>
> coordinates(grd) <- ~ x+y
>
> gridded(grd) <- TRUE
>
>
>
> g <- krige(formula=wert ~1, e, grd,model=vgm(1,"Exp",300))
>
>
>
> proj4string(g) = CRS("+init=epsg:4326")
>
> writeGDAL(g, "ordinary_kriging_1.tif", drivername="GTiff", type="Byte")
>
>
>
> Thanks
>
> Tarek
>
>
>
>
--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics e.pebesma at wwu.de
More information about the R-sig-Geo
mailing list