[R-sig-Geo] problem with gridded
Pierre Roudier
pierre.roudier at gmail.com
Wed Dec 15 22:03:49 CET 2010
Hi Agnieszka,
I do not understand your question, do you have an example?
Is the problem related to the color ramp of your plot?
2010/12/14 Agnieszka Kaczmarczyk <agnes.kaczmarczyk at gmail.com>:
> Pierre,
> Tkank You for help. I solve problem whit gridded.
> I have next question. How make to fit legend(scale) of plot? I use function
> points().
> Cheers,
> Agnieszka
>
> 2010/12/9 Pierre Roudier <pierre.roudier at gmail.com>
>>
>> Agnieszka,
>>
>> In your code, alu.sp as no attribute because it is an output of the
>> spsample function - it samples spatial locations, not the data itslef.
>> If you look at the class of your objects, alu is a
>> SpatialPointsDataFrame when alu.sp is a SpatialPoints, which means it
>> is just a set of spatial locations, without any attached data frame.
>>
>> Things will be much clearer if:
>> - you give us what exactly you want to achieve. What exactly do you
>> use this spsample function for?
>> - you use an embbeded data set like meuse, as I do not have your alu
>> data set and therefore can't reproduce your code. Just load it like
>> that:
>> data(meuse)
>> coordinates(meuse) <- ~x+y
>>
>> Cheers,
>>
>> Pierre
>>
>> 2010/12/10 Agnieszka Kaczmarczyk <agnes.kaczmarczyk at gmail.com>:
>> > Hello Pierre,
>> > Thank You for answer. It is full code that I use;
>> > class(alu)
>> > names(alu)
>> > coordinates(alu) = ~x+y
>> > class(alu)
>> > summary(alu)
>> > Object of class SpatialPointsDataFrame
>> > Coordinates:
>> > min max
>> > x 4384068 4393091
>> > y 5569911 5579336
>> > Is projected: NA
>> > proj4string : [NA]
>> > Number of points: 1393
>> > Data attributes:
>> > Min. 1st Qu. Median Mean 3rd Qu. Max.
>> > 0.0300 0.1400 0.3100 0.3799 0.5800 1.5000
>> > names(alu)
>> > [1] "al"
>> > dimensions(alu)
>> > (alu)[1:2,]
>> > coordinates al
>> > 1 (4384100, 5570080) 0.20
>> > 2 (4384070, 5570300) 0.15
>> > it is ok.
>> > alu.sp = spsample(alu, type = "regular", cellsize = c(50,50))
>> > summary(alu.sp)
>> > Object of class SpatialPoints
>> > Coordinates:
>> > min max
>> > x1 4384069 4393069
>> > x2 5569950 5579300
>> > Is projected: NA
>> > proj4string : [NA]
>> > Number of points: 34028
>> > Here atrributes is missing.
>> > I use functions;
>> > gridded(alu) = TRUE
>> > Error in points2grid(points, tolerance, round, fuzz.tol) :
>> > dimension 1 : coordinate intervals are not constant after allowing for
>> > numeric fuzz
>> > In addition: Warning message:
>> > In points2grid(points, tolerance, round, fuzz.tol) :
>> > grid has empty column/rows in dimension 1
>> > I can't solve this problem. I change to parameter function and nothing.
>> > I tried other funciton and scheme. It Is my frist problem in R.
>> > Agnieszka
>> >
>> > 2010/12/9 Pierre Roudier <pierre.roudier at gmail.com>
>> >>
>> >> Hi Agnieszka,
>> >>
>> >> This question is not easy to answer because unfortunately you gave
>> >> very few details. I assume you want to use the function gridded() on
>> >> your dataset alu.
>> >>
>> >> First thing you have to do is to make your dataset a Spatial object.
>> >> This is done using the coordinates() function:
>> >>
>> >> library(sp)
>> >> coordinates(alu) <- ~x+y # Again, I'm just guessing x and y are the
>> >> spatial coordinates
>> >> class(alu)
>> >>
>> >> The class of alu should be "SpatialDataFrame"
>> >>
>> >> If your data set is on a *regular* grid, you may want to use the
>> >> gridded() function to make alu a Grid:
>> >>
>> >> gridded(alu) <- TRUE
>> >>
>> >> At this point, you may have the following error:
>> >> suggested tolerance minimum: 0.142857142857143
>> >> Error in points2grid(points, tolerance, round, fuzz.tol) :
>> >> dimension 1 : coordinate intervals are not constant
>> >>
>> >> This means your data set is not regularly gridded. You may want to use
>> >> the points2grid function, which has a tolerance parameter.
>> >> If your dataset is not gridded, and you need to generate a prediction
>> >> grid (eg for kriging), I advise you to use the spsample function (see
>> >> ?spsample).
>> >>
>> >> hope this helps,
>> >>
>> >> Pierre
>> >>
>> >>
>> >> 2010/12/9 Agnieszka Kaczmarczyk <agnes.kaczmarczyk at gmail.com>:
>> >> > Hello,
>> >> > I have to gridded my data alu:
>> >> > class(alu)
>> >> > [1] "data.frame"
>> >> > alu[1:3,1:3]
>> >> > x y al
>> >> > 1 4384104 5570084 0.20
>> >> > 2 4384068 5570297 0.15
>> >> > 3 4384111 5570551 0.08
>> >> > I use function: gridded(), spsample(),points2grid(),GridTopology(),
>> >> > expand.grid() ect.
>> >> > I read The meuse data set: a tutorial for the gstat R package and
>> >> > other
>> >> > tutorial for R. I can't solve this problem. I'm interesting
>> >> > geostatistic
>> >> > simulation. Can you help me with my problem?
>> >> > With best regards,
>> >> > Agnieszka
>> >> >
>> >> > [[alternative HTML version deleted]]
>> >> >
>> >> > _______________________________________________
>> >> > R-sig-Geo mailing list
>> >> > R-sig-Geo at r-project.org
>> >> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>> >> >
>> >
>> >
>
>
More information about the R-sig-Geo
mailing list