[R-sig-Geo] The "comment" attribute in R spatial objects
Leigh, George
George.Leigh at daff.qld.gov.au
Fri Jul 19 05:12:36 CEST 2013
Roger suggested that I send this note to inform/remind subscribers about the use of the "comment" attribute in R spatial objects.
R spatial objects require the "comment" attribute to be consistent with the contents of the object. The functions in the libraries can give incorrect results otherwise. In my particular case, a "Polygons" object contained multiple polygons but the "comment" attribute was the string "0" which indicated that it contained only one polygon. Then the "gIntersection" function returned the intersection with only the first polygon, which was not what I wanted.
Users also need to be aware that the "comment" attribute is not displayed when an object is printed. If we want to know its value, we have to use R's "comment" function.
In general, it is safe to have NULL comment attributes. My problem was caused by using the "readWKT" function, which assigns a non-null comment field. If I had known this at the time, I could easily have fixed the problem by setting the comment field to NULL in the object after creating it in readWKT.
Roger has just introduced fixes to detect inconsistencies in the comment field, which will be included in new downloads of the software.
The use of comments is explained on page 47 of the second edition of the ASDAR book. (Unfortunately, I had only the first edition.) It came about because of the need for consistency with standards and other software. There is a function called "createSPComment" that can create the comments correctly, but as stated above it is generally safe to set all comment attributes to NULL.
------------------------------
The information in this email together with any attachments is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. There is no waiver of any confidentiality/privilege by your inadvertent receipt of this material.
Any form of review, disclosure, modification, distribution and/or publication of this email message is prohibited, unless as a necessary part of Departmental business.
If you have received this message in error, you are asked to inform the sender as quickly as possible and delete this message and any copies of this message from your computer and/or your computer system network.
More information about the R-sig-Geo
mailing list