[R] diffusing GIS data in maps
Paul Hiemstra
p.hiemstra at geo.uu.nl
Tue Aug 14 16:56:06 CEST 2007
Hi Lawrence,
You could use the gstat (geostatistics) package to perform an
interpolation, it also requires the package sp. It offers inverse
distance interpolation and several forms of kriging. Making an
interpolation would look something like:
library(gstat) # Also loads sp
coordinates(geocode) = ~LAT + LONG # make a spatial object out of
geocode
grid = spsample(geocode, type = "regular", n = 1000) # make a map of
target locations.
# Regular grid. n is the number
of cells, increase this for more detail in the resulting map
gridded(grid) = TRUE # Identifying this object as a grid
interpolated = krige(VALUE ~ 1, geocode, grid) # Do inverse distance
interpolation, data is 'geocode', target locations are 'grid'.
spplot(interpolated, "var1.pred", sp.layout = list("sp.points",
geocode)) # Plot the predictions (grid) and the points (geocode)
hope this helps,
Paul
Lawrence D. Brenninkmeyer schreef:
> Hi-
>
> I am trying to find a way to diffuse GIS data on a European map. I have a
> dataset consisting of particular locations scattered across Europe,
> along with magnitude and value information. I can plot these as discrete
> points with something like the following:
>
> "geocode" is a dataframe with four columns: LAT; LONG; MAGNITUDE;VALUE.
>
> library(maps)
> library(mapdata)
> map("worldHires", regions=c("Germany", "Belgium", "Netherlands"))
> points(geocode$LONG, geocode$LAT, cex=geocode$MAGNITUDE / 2500,
> col=rainbow(length(geocode$VALUE), start=0, end=.4)[rank(geocode$VALUE)])
>
> This gives me a map of Europe with my datapoints highlighted in two ways:
> magnitude is represented by the size of the point, and value is
> represented by the color.
>
> However, what I would really like is for there to be some sort of
> diffusion, such that instead of discrete points, the European map is
> covered in color so I can see more clearly whether there are regional
> patterns (something that will presumably look like this contour chart:
> <http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=20> only
> on the European map).
>
> I have absolutely no idea where to start because I can't find a function
> that will allow me to diffuse the datapoints on a map.
>
> thank you for any help
> ldb
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone: +31302535773
Fax: +31302531145
http://intamap.geo.uu.nl/~paul
More information about the R-help
mailing list