[R-sig-Geo] Better print method for Spatial*DataFrames?

Etienne Bellemare Racine etiennebr at gmail.com
Fri May 28 16:47:05 CEST 2010


I taught I could add my two cents.
> Nice suggestion!
I agree !
>> options(width=60)
>> print(meuse[1:3,], sWKT=T)
>>      
I don't know what's sWKT, but the folowing output is the kind of 
printing I would like by default. Sometimes I make the mistake of 
printing a spatial polygon data frame and it can take literally 5 
minutes to output. So if it could just be the default, I'd be happy.
>                geometry cadmium copper lead zinc  elev
> 1 POINT(333611 181072)    11.7     85  299 1022 7.909
> 2 POINT(333558 181025)     8.6     81  277 1141 6.983
> 3 POINT(333537 181165)     6.5     68  199  640 7.800
>          dist   om ffreq soil lime landuse dist.m
> 1 0.00135803 13.6     1    1    1      Ah     50
> 2 0.01222430 14.0     1    1    1      Ah     30
> 3 0.10302900 13.0     1    1    1      Ah    150
>
> For (multi)lines / polygons, would it be useful to print the first
> coordinate followed by ..., so that some kind of identification is possible?
>
>    
I think it's a good idea, but long output are always a pain to read. So 
I suggest someting compact. Maybe there could be kind of an offset 
before the display. So if you had like

POINT(349600.8 5387597)
POINT(349597.0 5387597)
POINT(349590.4 5387595)
POINT(349569.9 5387591)
POINT(349557.1 5387586)
POINT(349548.5 5387581)
POINT(349542.9 5387575)
...
Maybe it could print the coordinates as
349000+  5387500+
POINT(600.8 97)
POINT(597.0 97)
POINT(590.4 95)
POINT(569.9 91)
POINT(557.1 86)
POINT(548.5 81)
POINT(542.9 75)
...
Maybe the coordinate to display should be the "labpt" slot ? I think for 
a matter of identification someting compact is much more useful.
Talking about compactness, as I don't know of any way to put many 
geometry types in one class spatial*dataframe, is it necessary to repeat 
POINT, or (MULTI)LINE, or POLYGON ? Would it be possible to only display 
(random thaught here) P, M, L, Y? or S for surface ? I don't know. I 
like compactness !

Also, is it possible to add the same identifier (coordinate) to View() ?

Etienne



More information about the R-sig-Geo mailing list