<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
Le 06/12/2010 03:55, Sébastien Durand a écrit :
<blockquote cite="mid:D67111C4-6C94-4A1D-B9E5-7AC536C95663@gmail.com"
type="cite">
<pre wrap="">Here is what I found as a temporary solution:
Here is my example:
library(akima)
library(maptools)
library(zoo)
gpclibPermit()
library(raster)
data(akima)
# define de dimension of grid
dimgrid <- 50
# Interpolate to regular grid
ak.li <- interp(akima$x, akima$y, akima$z, xo=seq(min(akima$x),
max(akima$x), length = dimgrid),yo=seq(min(akima$y), max(akima$y),
length = dimgrid),linear = TRUE, extrap=FALSE, duplicate = "mean")
# Show interpolation
image(ak.li)
points(akima)
with(akima, text(x, y, formatC(z,dig=2), adj = -0.1))
r <- raster(ak.li)
plot(r)
pol <- rasterToPolygons(r, fun=function(x){x>20 & x<25})
# Show the polygons
plot(pol, add=T, col='red')
### new code
digits <- 6
for (i in 1:length(pol@polygons)) {
for (j in 1:length(pol@polygons[[i]]@Polygons)) {
pol@polygons[[i]]@Polygons[[j]]@coords <-
round(pol@polygons[[i]]@Polygons[[j]]@coords, digits)
}
}
# Attempt to merge similar adjacent into one polygon
union = unionSpatialPolygons(pol, ID=rep(1, times=length(pol@polygons)))
# Show
plot(union, add=TRUE, col="white")
# Nombre de vertices
crds=union@polygons[[1]]@Polygons[[1]]@coords
tmp=length(crds[,1])
nexCoordX= rollmean(c(crds[tmp,1], crds[,1], crds[1,1]), k=2)
nexCoordY= rollmean(c(crds[tmp,2], crds[,2], crds[1,2]), k=2)
lines(nexCoordX, nexCoordY, col="yellow", lwd=2)
If you have any knowledge of a function that would do something similar, I would be happy to ear about it!
Thanks a lot!
Sébastien
_______________________________________________
R-sig-Geo mailing list
<a class="moz-txt-link-abbreviated" href="mailto:R-sig-Geo@r-project.org">R-sig-Geo@r-project.org</a>
<a class="moz-txt-link-freetext" href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a>
</pre>
</blockquote>
Hey,<br>
<br>
Hey,<br>
<br>
You can also have a look at the spatstat package and the
simplify.owin() function. Maptools package provides function to convert
objects between sp and spatstat formats.<br>
HTH<br>
<br>
Alex<br>
<br>
<div class="moz-signature">-- <br>
<address> Alexandre Villers, PhD. <br>
Postdoc researcher<br>
Spatial Ecology & Population Dynamics<br>
Section of Ecology, Department of Biology<br>
University of Turku<br>
FIN-20014 Turku<br>
Finland<br>
<br>
@mail: alexandre.villers@utu.fi<br>
phone: 00358 (0)2 333 5039<br>
<br>
Skype <a href="skype:aquila06?call"><img
src="file://media/GrosDD/SignatureMail/Skypelogo.jpg"
style="border: medium none ;"
alt="You can skype me (but think of using Ekiga instead !)" height="50"></a></address>
<br>
<b>Use open source and free softwares</b><br>
<a href="http://cran.r-project.org/" title="R statistical software"><img
style="border-color: rgb(255, 255, 255);"
src="cid:part1.06030403.01040609@gmail.com" height="50"></a><spacer>
<a href="http://grass.itc.it/"
title="GIS software for data processing, easily replaces ArcMap and Mapinfo"><img
style="border-color: rgb(255, 255, 255);"
src="cid:part2.05060507.03080001@gmail.com" height="50"></a><a
href="http://www.qgis.org/"
title="GIS visualization, easily replaces ArcMap or Mapinfo"><img
style="border-color: rgb(255, 255, 255);"
src="cid:part3.08070508.08070806@gmail.com" height="50"></a> <spacer>
<a href="http://fr.openoffice.org/"
title="Stop using Microsoft Office !"><img
style="border-color: rgb(255, 255, 255);"
src="cid:part4.09040203.04070300@gmail.com" height="50"></a><a
href="http://www.mozilla-europe.org/fr/"
title="Stop using Microsoft Outlook !"><img
style="border-color: rgb(255, 255, 255);"
src="cid:part5.05070402.04050406@gmail.com" height="50"></a>
<a href="http://www.mozilla-europe.org/fr/"
title="Stop using Microsoft Internet Explorer !"><img
style="border-color: rgb(255, 255, 255);"
src="cid:part6.02040509.06070305@gmail.com" height="50"></a></div>
</body>
</html>