[R-sig-Geo] Rgdal GeoTIFF

Alexandre Villers villers.alexandre at gmail.com
Thu Dec 16 16:09:18 CET 2010


Hey Tarek,

I guess you have this issue because the g object has two bands.... (the 
estimated mean and variance or sd of your kriging, someone will correct 
me). So your writeGDAL() should be

writeGDAL(g[,,"band1"], "ordinary_kriging_1.tif", drivername="GTiff", 
type="Byte")

HTH

Alex


On 16/12/2010 16:52, 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
>
>
>
>


-- 
Alexandre Villers, PhD.
Postdoc researcher
Spatial Ecology & Population Dynamics
Section of Ecology, Department of Biology
University of Turku
FIN-20014 Turku
Finland

@mail: alexandre.villers at utu.fi
phone: 00358 (0)2 333 5039

Skype You can skype me (but think of using Ekiga instead !) 
<skype:aquila06?call>


*Use open source and free softwares*
<http://cran.r-project.org/> <http://grass.itc.it/> 
<http://www.qgis.org/> <http://fr.openoffice.org/> 
<http://www.mozilla-europe.org/fr/> <http://www.mozilla-europe.org/fr/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20101216/bc05643c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Skypelogo.jpg
Type: image/jpeg
Size: 5395 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20101216/bc05643c/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Rlogo.jpg
Type: image/jpeg
Size: 1753 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20101216/bc05643c/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GRASSlogo.png
Type: image/png
Size: 3277 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20101216/bc05643c/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: QGIS.png
Type: image/png
Size: 4144 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20101216/bc05643c/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OOlogo.gif
Type: image/gif
Size: 4246 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20101216/bc05643c/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TBlogo.jpg
Type: image/jpeg
Size: 1385 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20101216/bc05643c/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FFlogo.jpg
Type: image/jpeg
Size: 1686 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20101216/bc05643c/attachment-0003.jpg>


More information about the R-sig-Geo mailing list