[R-sig-Geo] nc in Rnews_2005-2.pdf
pir2.jv
pir2.jv at wanadoo.fr
Thu Sep 28 08:57:08 CEST 2006
I read Rnews_2005-2.pdf and I can't do the test.
For instance, on page 10:
maptools and sp are active,
> fname = system.file("shapes/sids.shp", package="maptools")
> p4s = CRS("+proj=longlat +datum=NAD27")
> nc = readShapePoly(fname, proj4string=p4s)
> plot(nc, axes = TRUE, col=grey(1-nc$SID79/57))
Erreur dans plot.window(xlim, ylim, log, asp, ...) :
'xlim' nécessite des valeurs finies
De plus : Warning messages:
1: aucun argument trouvé pour min ; Inf est renvoyé
2: aucun argument pour max ; -Inf est renvoyé
3: aucun argument trouvé pour min ; Inf est renvoyé
4: aucun argument pour max ; -Inf est renvoyé
How t resolve these problems ?
Thanks
JV
==============
nc is really a big thing !:
> class(nc)
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"
> str(nc)
Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots
..@ data :`data.frame': 100 obs. of 14 variables:
.. ..$ AREA : num [1:100] 0.114 0.061 0.143 0.07 0.153 0.097
0.062 0.091 0.118 0.124 ...
.. ..$ PERIMETER: num [1:100] 1.44 1.23 1.63 2.97 2.21 ...
.. ..$ CNTY_ : num [1:100] 1825 1827 1828 1831 1832 ...
.. ..$ CNTY_ID : num [1:100] 1825 1827 1828 1831 1832 ...
.. ..$ NAME : Factor w/ 100 levels "Alamance","Alexander",..:
5 3 86 27 66 46 15 37 93 85 ...
.. ..$ FIPS : Factor w/ 100 levels "37001","37003",..: 5 3 86
27 66 46 15 37 93 85 ...
.. ..$ FIPSNO : num [1:100] 37009 37005 37171 37053 37131 ...
.. ..$ CRESS_ID : num [1:100] 5 3 86 27 66 46 15 37 93 85 ...
.. ..$ BIR74 : num [1:100] 1091 487 3188 508 1421 ...
.. ..$ SID74 : num [1:100] 1 0 5 1 9 7 0 0 4 1 ...
.. ..$ NWBIR74 : num [1:100] 10 10 208 123 1066 ...
.. ..$ BIR79 : num [1:100] 1364 542 3616 830 1606 ...
.. ..$ SID79 : num [1:100] 0 3 6 2 3 5 2 2 2 5 ...
.. ..$ NWBIR79 : num [1:100] 19 12 260 145 1197 ...
.. ..- attr(*, "data_types")= chr [1:14] "N" "N" "N" "N" ...
..@ polygons :List of 100
.. ..$ :Formal class 'Polygons' [package "sp"] with 5 slots
.. .. .. ..@ Polygons :List of 1
.. .. .. .. ..$ :Formal class 'Polygon' [package "sp"] with 5 slots
.. .. .. .. .. .. ..@ labpt : num [1:2] -81.5 36.4
.. .. .. .. .. .. ..@ area : num 0.114
.. .. .. .. .. .. ..@ hole : logi FALSE
.. .. .. .. .. .. ..@ ringDir: int 1
.. .. .. .. .. .. ..@ coords : num [1:27, 1:2] -81.5 -81.5 -81.6
-81.6 -81.7 ...
.. .. .. ..@ plotOrder: int 1
.. .. .. ..@ labpt : num [1:2] -81.5 36.4
.. .. .. ..@ ID : chr "0"
.. .. .. ..@ area : num 0.114
.......
.. ..$ :Formal class 'Polygons' [package "sp"] with 5 slots
.. .. .. ..@ Polygons :List of 1
.. .. .. .. ..$ :Formal class 'Polygon' [package "sp"] with 5 slots
.. .. .. .. .. .. ..@ labpt : num [1:2] -78.3 34.1
.. .. .. .. .. .. ..@ area : num 0.212
.. .. .. .. .. .. ..@ hole : logi FALSE
.. .. .. .. .. .. ..@ ringDir: int 1
.. .. .. .. .. .. ..@ coords : num [1:27, 1:2] -78.7 -78.6 -78.6
-78.6 -78.6 ...
.. .. .. ..@ plotOrder: int 1
.. .. .. ..@ labpt : num [1:2] -78.3 34.1
.. .. .. ..@ ID : chr "99"
.. .. .. ..@ area : num 0.212
..@ plotOrder : int [1:100] 79 98 94 96 37 97 100 54 88 57 ...
..@ bbox : num [1:2, 1:2] -84.3 33.9 -75.5 36.6
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:2] "r1" "r2"
.. .. ..$ : chr [1:2] "min" "max"
..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
.. .. ..@ projargs: chr "+proj=longlat +datum=NAD27"
===================
I have:
> nc at bbox
min max
r1 -84.32385 -75.45698
r2 33.88199 36.58965
=========================
nc$SID79
[1] 0 3 6 2 3 5 2 2 2 5 2 5 4 4 6 17 4 7 1 0
1 0 1 0
[25] 18 38 11 5 6 22 7 2 9 9 1 1 31 2 5 3 2 8 15 0 0
5 12 3
[49] 13 8 11 21 18 13 8 1 4 2 4 6 8 23 10 21 7 5 5 35 20
8 7 8
[73] 1 14 4 26 0 3 4 1 1 57 2 9 4 6 0 7 7 0 18 16 23
26 4 5
[97] 3 17 9 6
=======================
> str(nc at polygons[[100]])
Formal class 'Polygons' [package "sp"] with 5 slots
..@ Polygons :List of 1
.. ..$ :Formal class 'Polygon' [package "sp"] with 5 slots
.. .. .. ..@ labpt : num [1:2] -78.3 34.1
.. .. .. ..@ area : num 0.212
.. .. .. ..@ hole : logi FALSE
.. .. .. ..@ ringDir: int 1
.. .. .. ..@ coords : num [1:27, 1:2] -78.7 -78.6 -78.6 -78.6
-78.6 ...
..@ plotOrder: int 1
..@ labpt : num [1:2] -78.3 34.1
..@ ID : chr "99"
..@ area : num 0.212
I tried:
> plot(nc at polygons[[100]], axes = TRUE, col=grey(1-nc$SID79/57))
Erreur dans plot.window(xlim, ylim, log, asp, ...) :
'xlim' nécessite des valeurs finies
De plus : Warning messages:
1: aucun argument trouvé pour min ; Inf est renvoyé
2: aucun argument pour max ; -Inf est renvoyé
3: aucun argument trouvé pour min ; Inf est renvoyé
4: aucun argument pour max ; -Inf est renvoyé
> Xlim= c(-84,-75)
> Ylim = c(33,37)
plot(nc at polygons[[100]], axes = TRUE, col=grey(1-nc
$SID79/57),xlim=Xlim,ylim=Ylim)
gives me no error, but a blank result, as:
> plot(nc, axes = TRUE, col=grey(1-nc$SID79/57),xlim=Xlim,ylim=Ylim)
I can't understand that:
> nc at polygons[[100]]
An object of class “Polygons”
Slot "Polygons":
[[1]]
An object of class “Polygon”
Slot "labpt":
[1] -78.25073 34.07663
Slot "area":
[1] 0.2116459
Slot "hole":
[1] FALSE
Slot "ringDir":
[1] 1
Slot "coords":
[,1] [,2]
[1,] -78.65572 33.94867
[2,] -78.63472 33.97798
[3,] -78.63027 34.01020
[4,] -78.58778 34.03061
[5,] -78.56343 34.05894
[6,] -78.54428 34.13416
[7,] -78.52724 34.15486
[8,] -78.49274 34.15850
[9,] -78.42543 34.13807
[10,] -78.36112 34.18672
[11,] -78.37357 34.20235
[12,] -78.26106 34.21526
[13,] -78.15479 34.36224
[14,] -78.13024 34.36412
[15,] -78.02592 34.32877
[16,] -78.01131 34.31261
[17,] -78.00702 34.28482
[18,] -77.99539 34.28280
[19,] -78.00022 34.26788
[20,] -77.98315 34.26168
[21,] -77.97528 34.24336
[22,] -77.96587 34.24229
[23,] -77.96073 34.18924
[24,] -77.95853 33.99258
[25,] -78.03481 33.91429
[26,] -78.57972 33.88199
[27,] -78.65572 33.94867
Slot "plotOrder":
[1] 1
Slot "labpt":
[1] -78.25073 34.07663
Slot "ID":
[1] "99"
Slot "area":
[1] 0.2116459
and +++++++++++++++++++++++++++++
> nc at polygons[[100]]@area
[1] 0.2116459
> nc at polygons[[100]]@ID
[1] "99"
> nc at polygons[[100]]@labpt
[1] -78.25073 34.07663
> nc at polygons[[100]]@plotOrder
[1] 1
but:
> nc at polygons[[100]]@coords
Erreur : aucun slot de nom "coords" pour cet objet de la classe
"Polygons"
> nc at polygons[[100]]@ringDir
Erreur : aucun slot de nom "ringDir" pour cet objet de la classe
"Polygons"
> nc at polygons[[100]]@hole
Erreur : aucun slot de nom "hole" pour cet objet de la classe "Polygons"
What differences ?
Jacques Vernin
More information about the R-sig-Geo
mailing list