[R-sig-Geo] Better print method for Spatial*DataFrames?
Roger Bivand
Roger.Bivand at nhh.no
Fri May 28 18:18:46 CEST 2010
On Fri, 28 May 2010, Etienne Bellemare Racine wrote:
> I taught I could add my two cents.
>> Nice suggestion!
> I agree !
No. Only for SpatialPointDataFrame objects, which is what it does already.
Please, understand that str() is a *much* better choice in effectively all
cases where summary() isn't used. For the Spatial* objects, set a
max.level=2 or similar, and you can *see* what is in it. The proposed
print() method for a big multiband raster will also run away with you. Do
str(), not print()!!!
library(maptools)
xx <- readShapeSpatial(system.file("shapes/sids.shp",
package="maptools")[1], IDvar="FIPSNO",
proj4string=CRS("+proj=longlat +ellps=clrk66"))
summary(xx)
str(xx, max.level=2)
To avoid having to remember to write max.level=2, could someone contribute
a generic str() for S4 Spatial*?
Roger
>>> 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
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list