[R-sig-Geo] shapefile errors and kriging limits

Roger Bivand Roger.Bivand at nhh.no
Sat Sep 1 00:48:31 CEST 2007


On Fri, 31 Aug 2007, Carlos A. Bastos M.Guerra wrote:

>
> Dear Roger,
>
> Regarding the shapefile question I think it was a memory problem because 
> I had 88000 points and wen I reduced the number of points to half it 
> worked fine.
>
> Regarding the second question: thanks for the help and your solution 
> almost solves my problems, but I forgot to tell you that I am running 
> this on Mac OS, so rgdal doesn't run (at least that I know of). Because 
> of this I am also strugling to find the correct method to optmise the 
> parameters to do the fiting of the variogram (sill, range and nugget), 
> that rgdal facilitates...

rdal is not a geostatistics package, so this is unclear. With this many 
observations, you will need to be careful with the maximum number of 
points included and/or the maximum distance.

>
> Can you recomend another package beside rgdal, or do you know of a 
> version that runs on Mac??

The rgdal package runs fine on OSX, but like other Unix platforms, you 
have to fulfill its external dependencies and then install from source. 
There are details for getting hold of the external dependencies on the 
Rgeo website. For your size of data, you should take the necessary time to 
do that.

Best wishes,

Roger

>
> Best regards,
> Carlos
>
>
>
>
>
> Em 30/08/2007, às 23:16, Roger Bivand escreveu:
>
> On Thu, 30 Aug 2007, Carlos Guerra wrote:
>
> Dear useRs,
>
> I am trying to convert the predictions of a kriging model into a
> shapefile but I am getting some errors and I am getting nowere with
> my solutions...
>
> Without the error messages and the output of sessionInfo(), it isn't easy to say.
>
>
> This is the code I am running:
>
> a <- data.frame(Id=seq(1,length(pred.grid[,1]),1),X=pred.grid[,
> 1],Y=pred.grid[,2])
> a_dbf <- data.frame(Id=seq(1,length(pred.grid[,1]),1), data=kc2$predict)
> shp_1 <- convert.to.shapefile(a, a_dbf, field="Id", type=1)
>
> were pre.grid is determined by this code:
>
> min_x <- 142794
> max_x <- 152121
> min_y <- 485080
> max_y <- 508887
> pred.grid <- expand.grid(seq(min_x, max_x, 50), seq(min_y, max_y, 50))
>
> and kc2 is an object returned by the aplication of the function
> krige.conv:
>
> kc2 <- krige.conv(dados_g, loc=pred.grid, krige=krige.control
> (obj.m=vario_fit2))
>
>
> Although you are free to use the shapefiles package, your questions suggest that you might be better served by using sp classes and either maptools or rgdal to read and write your files. If you read the points data with readOGR() or readShapePoints(), created a GridTopology for your grid, and used the overlay() method from sp to cookie-cut the grid with a SpatialPolygonsDataFrame object read by readShapePoly() or readOGR(), and then simply passed coordinates() of the SpatialPixelsDataFrame object created after the overlaying to the loc= argument, you would be very close. Use bbox() of the imported SpatialPointsDataFrame object to find out what the grid should be. Consider reading the vignette of the sp package - and finally just output the SpatialPixelsDataFrame augmented with the prediction as a new column as a GeoTiff file using writeGDAL() in rgdal, choosing only the predictions.
>
> There are a number of steps to take, but it does work.
>
> Hope this helps,
>
> Roger
>
>
>
>
> Another question:
>
> as you can see I am predicting my values to a square set of points...
> my question is how can I can I generate a set of point that match a
> specific area (because I have a specific limite(area) in an esri's
> shapefile).
>
>
>
> Thanks in advance.
> Carlos
>
>
>
> Carlos GUERRA
>
> Gabinete de Sistemas de Informacao Geografica
> Escola Superior Agraria de Ponte de Lima
> Mosteiro de Refoios do Lima
> 4990-706 Ponte de Lima
>
> Tlm: +351 91 2407109
> Tlf: +351 258 909779
>
> Be a Mac user... update your self!
>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no


More information about the R-sig-Geo mailing list