Alí Santacruz | 1 Jul 2006 01:56
Picon
Favicon

universal kriging in gstat

Dear list members,

I am trying to perform universal kriging in gstat, and according to the help 
of 'krige' function, the names of the coordinates of 'newdata' argument must 
be the same as defined in 'locations'.

I am creating an SpatialPixels object for the prediction locations, using 
the next code:

>pts<-spsample(myShapePoly, n=3000, "regular")
>gridded(pts) <- TRUE class(pts)
[1] "SpatialPixels"
attr(,"package")
[1] "sp"

And x1 and x2 are the names of the coordinates of the prediction locations 
grid.

So, to perform universal kriging, I have to change the names of the 
coordinates of my observed data to x1 and x2, but I would like to know if I 
can change the name of the coordinates of the prediction grid ('pts').

I appreciate any comment. Sincerely,

Alí M. Santacruz
M.Sc. Geomatics, Student
National University of Colombia
Bogotá D.C.
karl.sommer | 3 Jul 2006 08:01
Picon
Favicon

Re: distance calculation; meuse.grid


Hello

I was wondering if there is a way in "R" or "sp" to calculate shortest
distance from a given object such as a river, similar to the data example
"meuse.grid"  under the gstat package. I was wondering how the "dist"
variable in the "meuse.grid"  file was orignially calculated?  I would like
to perform a similar calculation as shortest distance for each point in a
field (1m x 1m grid) from an irrigation channel for which I have generated
a shape file.  Or is such an operation better performed in a GIS
environment?

Regards

Karl
Roger Bivand | 3 Jul 2006 11:11
Picon

Re: distance calculation; meuse.grid

On Mon, 3 Jul 2006 karl.sommer <at> dpi.vic.gov.au wrote:

> 
> Hello
> 
> I was wondering if there is a way in "R" or "sp" to calculate shortest
> distance from a given object such as a river, similar to the data example
> "meuse.grid"  under the gstat package. I was wondering how the "dist"
> variable in the "meuse.grid"  file was orignially calculated?  I would like
> to perform a similar calculation as shortest distance for each point in a
> field (1m x 1m grid) from an irrigation channel for which I have generated
> a shape file.  Or is such an operation better performed in a GIS
> environment?

You can use spDistsN1() in sp to measure distances from many points to one 
point, including Great Circle distances. This will not be good enough for 
distances between other kinds of objects, so a GIS is the obvious choice 
for that. My guess for the origins of the meuse.grid distances is 
PCRaster, a raster GIS. If your irrigation channel has a lot of detail, 
you could use spDistsN1 in a loop between the grid of points and each 
point representing the channel, but it would be very messy, a GIS is 
designed to do this.

Roger

> 
> Regards
> 
> Karl
> 
(Continue reading)

Adrian Baddeley | 3 Jul 2006 12:30
Picon
Picon
Favicon

distance calculation; meuse.grid


karl.sommer <at> dpi.vic.gov.au writes:

> I was wondering if there is a way in "R" or "sp" to calculate shortest
> distance from a given object such as a river, similar to the data example
> "meuse.grid"  under the gstat package.

In package 'spatstat' there is a function distmap() 
designed for this purpose. 

The object (the river) may be either

	  - a list of line segments (line segment pattern object, class "psp")

	  - a list of x,y coordinate points (point pattern object, class "ppp")

or
	  - a binary pixel image (window object, class "owin", type "mask")

The return value is a pixel image; the brightness value of each pixel
gives the shortest distance from that pixel to the target object. 

You can display the pixel image, extract the values at chosen locations
using the subset operator "[ ]", or extract the entire pixel array
using "as.matrix".

Adrian Baddeley
Roger Bivand | 3 Jul 2006 15:40
Picon

Re: distance calculation; meuse.grid

On Mon, 3 Jul 2006, Adrian Baddeley wrote:

> 
> karl.sommer <at> dpi.vic.gov.au writes:
> 
> > I was wondering if there is a way in "R" or "sp" to calculate shortest
> > distance from a given object such as a river, similar to the data example
> > "meuse.grid"  under the gstat package.
> 
> In package 'spatstat' there is a function distmap() 
> designed for this purpose. 

Excellent! I'll add suitable functions to the sourceforge repository 
spspatstat package to interface sp classes to this solution, probably 
within a month. The as.mask() arguments can be derived from a SpatialGrid 
GridTopology slot, so this will help more people. Visiting 

http://www.spatstat.org/

is always instructive!

> 
> The object (the river) may be either
> 
> 	  - a list of line segments (line segment pattern object, class "psp")
> 
> 	  - a list of x,y coordinate points (point pattern object, class "ppp")
> 
> or
> 	  - a binary pixel image (window object, class "owin", type "mask")
(Continue reading)

Edzer J. Pebesma | 3 Jul 2006 17:40
Picon
Favicon

Re: universal kriging in gstat

Alí Santacruz wrote:
> Dear list members,
>
> I am trying to perform universal kriging in gstat, and according to the help 
> of 'krige' function, the names of the coordinates of 'newdata' argument must 
> be the same as defined in 'locations'.
>   
I suspect it is time to update this documentation; If you're using sp
objects, the names of coordinates does not play a role anymore, as
we can retrieve them using the coordinates() method.

Does this help?
--
Edzer
> I am creating an SpatialPixels object for the prediction locations, using 
> the next code:
>
>   
>> pts<-spsample(myShapePoly, n=3000, "regular")
>> gridded(pts) <- TRUE class(pts)
>>     
> [1] "SpatialPixels"
> attr(,"package")
> [1] "sp"
>
> And x1 and x2 are the names of the coordinates of the prediction locations 
> grid.
>
> So, to perform universal kriging, I have to change the names of the 
> coordinates of my observed data to x1 and x2, but I would like to know if I 
(Continue reading)

Alí Santacruz | 3 Jul 2006 18:07
Picon
Favicon

Re: universal kriging in gstat

Thanks Edzer,

Yes, I found that the answer was very simple: as you say, we can use the 
coordinates() method.

Best regards,

Alí Santacruz

>From: "Edzer J. Pebesma" <e.pebesma <at> geo.uu.nl>
>To: Alí Santacruz <amsantac <at> hotmail.com>
>CC: r-sig-geo <at> stat.math.ethz.ch
>Subject: Re: [R-sig-Geo] universal kriging in gstat
>Date: Mon, 03 Jul 2006 17:40:27 +0200
>
>Alí Santacruz wrote:
>>Dear list members,
>>
>>I am trying to perform universal kriging in gstat, and according to the 
>>help of 'krige' function, the names of the coordinates of 'newdata' 
>>argument must be the same as defined in 'locations'.
>>
>I suspect it is time to update this documentation; If you're using sp
>objects, the names of coordinates does not play a role anymore, as
>we can retrieve them using the coordinates() method.
>
>Does this help?
>--
>Edzer
>>I am creating an SpatialPixels object for the prediction locations, using 
(Continue reading)

Vladimir Batagelj | 4 Jul 2006 02:01
Picon

Line width in sp maps


Hi,

I am trying to change the line width in (shape) maps
produced using sp package, but without success.
All my attempts with lwd parameter failed.
I found a brute force solution to save the map in
EPS and change the linewidth there - but I would
expect that there is a regular solution.

best regards,  Vladimir Batagelj

--

-- 
Vladimir Batagelj, University of Ljubljana, Department of Mathematics
  Jadranska 19, PO Box 2964, 1111 Ljubljana, Slovenia
http://vlado.fmf.uni-lj.si
karl.sommer | 4 Jul 2006 06:33
Picon
Favicon

Re: error message rgdal: dimensions do not match


I am encountering a error message when attempting to do "inverse distance
kriging" or variogram calculations. The error is always the same

ERROR: dimensions do not match: locations 1513600 and data 611452.

What puzzles me is the fact that I am using the same code as I have
successfully
used with 2 other images.

I have tried to reduce the dimensions of the imported image in using
gdal_translate from the command prompt. The same error was still present
but with different "address-numbers" relating to locations and data.

I have tried to find some pointers re error messages under the GDAL
manual but without success.

I am able to plot the imported image as well as the target grid and SPDF
without error.

following is the code:

library(rgdal)
# import image
> t1 <- readGDAL("images/test1.bil", half.cell=c(0.5, 0.5), silent = FALSE)

images/test1.bil has GDAL driver GTiff
and has 860 rows and 880 columns

Closing GDAL dataset handle 0100ACB8...  destroyed ... done.
(Continue reading)

zhijie zhang | 4 Jul 2006 10:03
Picon

how do we sample in spatial statistics?

Dear friends,
  Sorry for sending an empty email because of mismanipulation.
  Do we also use sample() function to do the spatial sampling? I look for
the sample() and think it's one-dimensional sampling.
In spatial statistics, do we need two-dimentional sampling or some other
sampling techniques? Which functions could be used in spatial samping in R?
thanks very much!

--

-- 
Kind Regards,

	[[alternative HTML version deleted]]

Gmane