[adegenet-forum] converting s.image sPCA maps to shapefiles
Jombart, Thibaut
t.jombart at imperial.ac.uk
Tue Feb 7 17:07:56 CET 2012
Hello,
no there is no immediate conversion of the output of s.image to a shapefile. That would arguably be a poor strategy since s.image is a pixmap, so vectorizing it should probably be made within the SIG anyway.
>From another post to this forum (http://lists.r-forge.r-project.org/pipermail/adegenet-forum/2009-September/000060.html):
##########
library(akima)
library(maps)
library(mapdata)
GRID.RES <- 500
## original values
x <- seq(100,170,le=10) + runif(10,-5,5)
y <- seq(-50,0,le=10) + runif(10,-5,5)
z <- x*y + rnorm(length(x),2)
## interpolation using akima
x0 <- seq(100,170,le=GRID.RES)
y0 <- seq(-50,0,le=GRID.RES)
z.hat <- interp(x,y, z, xo=x0, yo=y0, linear = FALSE, extrap=TRUE)
## find loc in australia, set others to NA
myGrid <- expand.grid(x0, y0)
temp <- map.where(x=myGrid[,1], y=myGrid[,2])
toKeep <- grep("australia",temp, ignore.case=TRUE)
toRemove <- setdiff(1:length(z.hat$z), toKeep)
z.hat$z[toRemove] <- NA
## plot
image(z.hat)
map(add=TRUE, lwd=3)
contour(z.hat,add=TRUE)
############
This example shows how to make an interpolated map of any quantitative variable. It is very to adapt to sPCA predictions (use $li or $ls instead of z).
All the best
Thibaut
--
######################################
Dr Thibaut JOMBART
MRC Centre for Outbreak Analysis and Modelling
Department of Infectious Disease Epidemiology
Imperial College - School of Public Health
St Mary’s Campus
Norfolk Place
London W2 1PG
United Kingdom
Tel. : 0044 (0)20 7594 3658
t.jombart at imperial.ac.uk
http://sites.google.com/site/thibautjombart/
http://adegenet.r-forge.r-project.org/
________________________________________
From: adegenet-forum-bounces at r-forge.wu-wien.ac.at [adegenet-forum-bounces at r-forge.wu-wien.ac.at] on behalf of john benson [smilodon2000 at hotmail.com]
Sent: 06 February 2012 21:14
To: adegenet-forum at r-forge.wu-wien.ac.at
Subject: [adegenet-forum] converting s.image sPCA maps to shapefiles
Hi All,
I was wondering if anyone knows if its possible to convert a cline map (created with s.image function after running an sPCA) into a shapefile?
Here is my code for the map:
s.image(Datum3 at other$xy, mySpca1$li[,1],include.orig=FALSE, origin = c(0,0), span=0.5, image.plot=TRUE, pixmap=NULL, kgrid=30, cgrid=0, area=NULL)
Now I'd like to convert this into shapefile so i can create a figure with points, other shapefiles, etc in ArcGis.
Any help here would be appreciated....
Thanks!
John
John Benson, PhD Candidate
Trent University
Peterborough, ON, Canada
More information about the adegenet-forum
mailing list