[R-sig-Geo] I NEED Help with this spatial polygon problems (REALLY) Thanks really thanks

gianni lavaredo gianni.lavaredo at gmail.com
Wed Apr 1 12:21:07 CEST 2009

```Thanks Dott. Milton and Thanks Prof. Bivand,

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?

I import my polygon shape-file with readOGR

> summary(singleGap)
Object of class SpatialPolygonsDataFrame
Coordinates:
min       max
r1  268136.9  268881.3
r2 4147539.6 4147794.8
Is projected: TRUE
proj4string :
[+init=epsg:26911 +proj=utm +zone=11 +ellps=GRS80 +datum=NAD83 +units=m
+no_defs +towgs84=0,0,0]
Data attributes:
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
0       0       0       0       0       0

PBSmapping I need to Convert the SpatialPolygonDataFrame into a PolySet
object for compatibility. I use this code

singleGapPBS <- SpatialPolygons2PolySet(singleGap)
now  "singleGapPBS" is a PolySet and I can apply my function:

singleGap.area <- calcArea(singleGapPBS)

str(singleGap.area)
Classes ‘PolyData’ and 'data.frame':    839 obs. of  3 variables:
\$ PID : int  1 2 3 4 5 6 7 8 9 10 ...
\$ SID : int  1 1 1 1 1 1 1 1 1 1 ...
\$ area: num  1 4 1 1 1 1 2 48 3 9 ...
Now "singleGap.area" is a ‘"PolyData" and "data.frame". Every polygon under
5 m2 is a error and I need to eliminate.

singleGap.area <- singleGap.area[singleGap.area\$area >= 5,]
> str(singleGap.area)
Classes ‘PolyData’ and 'data.frame':    179 obs. of  3 variables:
\$ PID : int  8 10 17 21 30 33 36 40 48 49 ...
\$ SID : int  1 1 1 1 1 1 1 1 1 1 ...
\$ area: num  48 9 13 8 36 ...
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

Gianni

2009/4/1 Roger Bivand <Roger.Bivand at nhh.no>

> On Wed, 1 Apr 2009, gianni lavaredo wrote:
>
> Hey All,
>>
>> I have this problem and I need really help to understand (my limit) . I
>> have
>> a polygon shape file and I need to calculate some index and select the
>> polygon with correct index value. I DID this with library(PBSmapping), but
>> I
>> need to obtain new polygon shapefile
>>
>> # Convert the SpatialPolygonDataFrame into a PolySet object for
>> compatibility
>> # with the so that PBSMapping package's geospatial functions
>>
>> singleGapPBS <- SpatialPolygons2PolySet(singleGap)
>> # Calcula AREA
>> singleGap.area <- calcArea(singleGapPBS)
>> str(singleGap.area)
>>
>> # Calcula PERIMETER
>> singleGap.perimeter <- calcLength(singleGapPBS)
>> str(singleGap.perimeter)
>>
>> singleGap.Index <-
>> data.frame(singleGap.area[,c(1,3)],singleGap.perimeter[,3])
>> names(singleGap.Index)[3] = "perimeter"
>> str(singleGap.Index)
>>
>
> 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.
>
> Roger
>
>
>> singleGap.Index <- singleGap.Index[singleGap.Index\$area >= 5
>> |singleGap.Index\$area < 1000,]
>> NOW I TRYING SEVERAL METHOD BUT NOTHING. Thank, really thanks
>>
>> Gianni
>>
>>        [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> 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
> Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
> e-mail: Roger.Bivand at nhh.no
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20090401/02e50642/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: singleGAP.zip
Type: application/zip
Size: 39403 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20090401/02e50642/attachment.zip>
```