[R-sig-Geo] dotsInPolys sometimes not generating correct number of points
Nick Eubank
nickeubank at gmail.com
Sat Sep 24 01:11:24 CEST 2016
Hi All,
Trying to run dotsInPolys from maptools on a set of polygons. I have one
set of polygons for each US state, along with a vector of desired points
for each polygon.
However, when I check the number of dots created after running the code, I
find that for some states -- but not all -- the number of points doesn't
match the number of dots that were specified. In particular, I seem to have
fewer dots than expected.
Paraphrasing somewhat (haven't come up with a minimal replicating example I
can post, sorry), I have a polygon file called `my.polygons`, and I'm
effectively doing the following:
my.dots <- dotsInPolys(my.polygons, my.polygons[,'count.vector'])
I've confirmed that `typeof(my.polygons[,'count.vector'])` is `"integer"`,
and get no warnings running dotsInPolys. Nevertheless, for many states, I
get FALSE from:
length(my.dots) == sum(my.polygons$count.vector)
There are no NAs in the count vector.
No zero-area polygons. using rgeos, one state that is having problems
reports areas of:
summary(gArea(my.polygons, byid=TRUE))
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.474e+04 9.858e+05 4.264e+06 3.189e+07 3.159e+07 1.144e+09
I also get `gIsValid(my.polygons)` is TRUE, so it's not that...
It seems like I get more problems in states with more polygons / counts, if
that's at all informative. For example, one problem state has 3,671
polygons, and should have 634,397 points, but only ends up with 632,474.
Another with 6,983 polygons should have 3,942,589 points, but has
only 3,840,180. By contrast, no problems in a state with 343 polygons
and 120,397 points.
Any suggestions on possible cause?
Thanks,
Nick
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list