[R-sig-Geo] maptools/kmlPolygon example: two SPDFs, different results

rick reeves reeves at nceas.ucsb.edu
Thu Aug 27 18:27:53 CEST 2009


Hello List:

I'm using R 2.9 on Windows XP/64 for this example, with recent builds of 
maptools and rgdal packages.

The shape file used in this example can be obtained from:

http://nceas.ucsb.edu/scicomp/upload/UsCountiesGeogProj.zip

While studying the example for kmlPolygon() in the maptools.pdf 
documentation (pp 22  - 23), I ran the
example code (top of page 23), using the wrld_simpl data set, and used 
slot() to extract a subset of the
Polygons component of the sample data set, then create a KML file using 
kmlPolygon. The example
worked as planned with the indicated data set.

Then, I read the attached polygon shape file using readOGR, into a 
SpatialPolygonsDataFrame, and
substituted this dataset for the wrld_simpl data set. In this case, the 
slot() statement returned ONLY
the FIRST polygon from the SPDF. As a result, the resulting KML file 
contains only one polygon,
instead of the entire set.

I have reviewed the structure of each SPDF, using 'str(MySPDF[1:3,])', 
and the data objects seem
to have the same structure. Yet the 'one polygon' problem persists. I 
would appreciate it if someone
could repeat the experiment with the attached data set and let me know 
where I might be mistaken!

Thanks,
Rick Reeves

-- 
Rick Reeves
Scientific Programmer/Analyst and Data Manager
National Center for Ecological Analysis and Synthesis
UC Santa Barbara
www.nceas.ucsb.edu
805 892 2533



More information about the R-sig-Geo mailing list