[R-sig-Geo] Looping over spatial data

Jason Bryer jason at bryer.org
Thu Sep 10 17:16:49 CEST 2009


Sorry for what may be a simple question. I am having an issue looping  
over spatial data. Here is the code:

usa.map = read.shape(file.choose()) #Shape file of the US, 51 records

pt = data.frame(x=-73.793, y=42.857)
shapes = Map2poly(usa.map)
shape = shapes[[35]] #This is New York

pip(pt, shape) #This works, returns the point as I expect since it is  
within NY

for(i in 1:length(shapes)) {
	shape = shapes[[i]]
	pip(pt, shape)
	#This is where the error occurs
}

This is the error I get:

Error in inout(pt, shape) : NA/NaN/Inf in foreign function call (arg 4).

Thanks for any help.

-Jason



More information about the R-sig-Geo mailing list