Skip to content
Prev 6436 / 29559 Next

Looping over spatial data

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