<div>Thanks Dott. Milton and Thanks Prof. Bivand,</div>
<div> </div>
<div>Dear Prof. Bivand thanks for your attention and sorry for my not experience, every day I learn a little step in the huge R world. I am using "PBSmapping" because in this package there are some useful function for my study (Area, Perimeter, etc, etc). I have my first question: Is there another package to calculate this metrics?</div>
<div> </div>
<div>I import my polygon shape-file with readOGR</div>
<div> </div>
<div>> summary(singleGap)<br>Object of class SpatialPolygonsDataFrame<br>Coordinates:<br> min max<br>r1 268136.9 268881.3<br>r2 4147539.6 4147794.8<br>Is projected: TRUE <br>proj4string :<br>[+init=epsg:26911 +proj=utm +zone=11 +ellps=GRS80 +datum=NAD83 +units=m<br>
+no_defs +towgs84=0,0,0]<br>Data attributes:<br> Min. 1st Qu. Median Mean 3rd Qu. Max. <br> 0 0 0 0 0 0 <br><br></div>
<div>singlegap is a "SpatialPolygonsDataFrame". I had read that to apply PBSmapping I need to Convert the SpatialPolygonDataFrame into a PolySet object for compatibility. I use this code</div>
<div> </div>
<div>singleGapPBS <- SpatialPolygons2PolySet(singleGap)<br></div>
<div>now "singleGapPBS" is a PolySet and I can apply my function:</div>
<div> </div>
<div>singleGap.area <- calcArea(singleGapPBS)</div>
<div> </div>
<div>str(singleGap.area)<br>Classes ‘PolyData’ and 'data.frame': 839 obs. of 3 variables:<br> $ PID : int 1 2 3 4 5 6 7 8 9 10 ...<br> $ SID : int 1 1 1 1 1 1 1 1 1 1 ...<br> $ area: num 1 4 1 1 1 1 2 48 3 9 ...<br>
</div>
<div>Now "singleGap.area" is a ‘"PolyData" and "data.frame". Every polygon under 5 m2 is a error and I need to eliminate.</div>
<div> </div>
<div>singleGap.area <- singleGap.area[singleGap.area$area >= 5,]<br>> str(singleGap.area)<br>Classes ‘PolyData’ and 'data.frame': 179 obs. of 3 variables:<br> $ PID : int 8 10 17 21 30 33 36 40 48 49 ...<br>
$ SID : int 1 1 1 1 1 1 1 1 1 1 ...<br> $ area: num 48 9 13 8 36 ...<br></div>
<div>here I am trying a method to convert this in an " as.PolySet" and write a new Polygon shapefile. but this a my day limit. Sorry</div>
<div> </div>
<div>Gianni</div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div class="gmail_quote">2009/4/1 Roger Bivand <span dir="ltr"><<a href="mailto:Roger.Bivand@nhh.no">Roger.Bivand@nhh.no</a>></span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div class="im">On Wed, 1 Apr 2009, gianni lavaredo wrote:<br><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hey All,<br><br>I have this problem and I need really help to understand (my limit) . I have<br>a polygon shape file and I need to calculate some index and select the<br>
polygon with correct index value. I DID this with library(PBSmapping), but I<br>need to obtain new polygon shapefile<br><br>singleGap <- readOGR(".", "singleGap")<br># Convert the SpatialPolygonDataFrame into a PolySet object for<br>
compatibility<br># with the so that PBSMapping package's geospatial functions<br><br>singleGapPBS <- SpatialPolygons2PolySet(singleGap)<br># Calcula AREA<br>singleGap.area <- calcArea(singleGapPBS)<br>str(singleGap.area)<br>
<br># Calcula PERIMETER<br>singleGap.perimeter <- calcLength(singleGapPBS)<br>str(singleGap.perimeter)<br><br>singleGap.Index <-<br>data.frame(singleGap.area[,c(1,3)],singleGap.perimeter[,3])<br>names(singleGap.Index)[3] = "perimeter"<br>
str(singleGap.Index)<br></blockquote><br></div>Which says what? Is singleGap.Index[[1]] named area? Is it a vector or a data frame? I think that singleGap.Index isn't what you think it is, meaning that singleGap.Index$area is NULL, and subsetting will not work.<br>
<br>Roger<br><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div class="im"><br>singleGap.Index <- singleGap.Index[singleGap.Index$area >= 5<br>|singleGap.Index$area < 1000,]<br>NOW I TRYING SEVERAL METHOD BUT NOTHING. Thank, really thanks<br><br>Gianni<br><br></div>
<div class="im"> [[alternative HTML version deleted]]<br><br>_______________________________________________<br>R-sig-Geo mailing list<br><a href="mailto:R-sig-Geo@stat.math.ethz.ch" target="_blank">R-sig-Geo@stat.math.ethz.ch</a><br>
<a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br><br></div></blockquote><font color="#888888"><br>-- <br>Roger Bivand<br>Economic Geography Section, Department of Economics, Norwegian School of<br>
Economics and Business Administration, Helleveien 30, N-5045 Bergen,<br>Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43<br>e-mail: <a href="mailto:Roger.Bivand@nhh.no" target="_blank">Roger.Bivand@nhh.no</a><br><br></font></blockquote>
</div><br>