stackoverflow community,
I have two shapefiles of the municipalities of Japan. I'm using R to create separate plots for each of the municipalities. I can make this work with one shapefile, but the identical syntax fails with the other. Here are the code and the URLs for the data:
library(sp)
library(maptools)
# Map A - this one works
# Please download: http://www.filefactory.com/file/z26nirxoz53/n/JPN_adm_zip
# Enter your path for readShapePoly
japanMapA = readShapePoly("JPN_adm/JPN_adm2")
names(japanMapA)
plot(japanMapA[japanMapA$ID_2 == 1199,])
# Map B - this one doesn't work
# Please download: http://geocommons.com/overlays/173340.zip
# Again, enter your path for readShapePoly
japanMapB = readShapePoly("japan_ver71")
names(japanMapB)
plot(japanMapB[japanMapB$JCODE == 45382,])
The error it throws is:
Error in plot(japanMapB[japanMapB$JCODE == 45382, ]) :
error in evaluating the argument 'x' in selecting a method for function 'plot': Error in japanMapB[japanMapB$JCODE == 45382, ] :
NAs not permitted in row index
I don't know how to go about removing the NAs in this case, so I am unable to plot the individual elements.
Would greatly appreciate your help: have been banging my head against the wall for a while on this one!