May be this work for rectangular image.
   
  require(rimage)
  img<-read.jpeg("file.jpg")
image(rgb2grey(img))
  nsamples<-1000
  coordinates<-NULL
for (i in 1:nsamples) {
 coordinates<-rbind(
  coordinates,
  cbind(x=as.integer(nrow(img)*runif(1)),
  y=as.integer(ncol(img)*runif(1))))
 }
  
 
  But I sugest you give a look at "adehabitat" and "rimage" packages.
   
  Best,
   
  Miltinho

ronggui <ronggui.huang@gmail.com> escreveu:
  I have a map of a district (which is JPG format), and I want to do a
sptial sampling based on the map. So is there any function to do
spatial sampling of this type?

Thanks!

-- 
Ronggui Huang
Department of Sociology
Fudan University, Shanghai, China
黄荣贵
复旦大学社会学系

______________________________________________
R-help@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.


 		
---------------------------------
 
	[[alternative HTML version deleted]]

