从SpatialPolygonsDataFrame中删除某些多边形

时间:2015-04-28 17:31:01

标签: r spatial

我是R在使用SpatialPolygonsDataFrames的新手,我正在努力弄清楚如何从我的SPDF对象中删除不需要的多边形。我有一个包含岛屿和大陆的多边形,我想删除这些岛屿。这是我的SPDF的样子:

An object of class "SpatialPolygonsDataFrame"
Slot "data":
  STATEFP10 PUMACE10       AFFGEOID10 GEOID10                                                 NAME10 LSAD10
2        06    07501 7950000US0607501 0607501 San Francisco County (North & West)--Richmond District     P0
   ALAND10  AWATER10
2 25002405 344341857

Slot "polygons":
[[1]]
An object of class "Polygons"
Slot "Polygons":
[[1]]
An object of class "Polygon"
Slot "labpt":
[1] -122.47642   37.83182

Slot "area":
[1] 8.62403e-06

Slot "hole":
[1] FALSE

Slot "ringDir":
[1] 1

Slot "coords":
           [,1]     [,2]
 [1,] -122.4795 37.83042
 [2,] -122.4781 37.83246
 [3,] -122.4742 37.83337
 [4,] -122.4728 37.83201
 [5,] -122.4727 37.83203
 [6,] -122.4727 37.83193
 [7,] -122.4782 37.83136
 [8,] -122.4786 37.82862
 [9,] -122.4795 37.83042


[[2]]
An object of class "Polygon"
Slot "labpt":
[1] -122.49813   37.82161

Slot "area":
[1] 4.535181e-06

Slot "hole":
[1] FALSE

Slot "ringDir":
[1] 1

Slot "coords":
          [,1]     [,2]
[1,] -122.4990 37.82233
[2,] -122.4963 37.82236
[3,] -122.4955 37.82243
[4,] -122.4990 37.82023
[5,] -122.4999 37.82182
[6,] -122.4990 37.82233


[[3]]
An object of class "Polygon"
Slot "labpt":
[1] -122.46946   37.78285

Slot "area":
[1] 0.002532896

Slot "hole":
[1] FALSE

Slot "ringDir":
[1] 1

Slot "coords":
           [,1]     [,2]
 [1,] -122.5145 37.78083
 [2,] -122.5053 37.78831
 [3,] -122.4929 37.78793
 [4,] -122.4858 37.79061
 [5,] -122.4858 37.79063
 [6,] -122.4803 37.80129
 [7,] -122.4781 37.81083
 [8,] -122.4777 37.81072
 [9,] -122.4762 37.81031
[10,] -122.4705 37.80872
[11,] -122.4705 37.80870
[12,] -122.4703 37.80867
[13,] -122.4663 37.80618
[14,] -122.4638 37.80465
[15,] -122.4482 37.80725
[16,] -122.4484 37.80622
[17,] -122.4483 37.80472
[18,] -122.4482 37.80448
[19,] -122.4488 37.80423
[20,] -122.4494 37.80371
[21,] -122.4496 37.80279
[22,] -122.4492 37.80207
[23,] -122.4484 37.80159
[24,] -122.4478 37.80163
[25,] -122.4477 37.80068
[26,] -122.4473 37.79846
[27,] -122.4464 37.79281
[28,] -122.4463 37.79188
[29,] -122.4454 37.78744
[30,] -122.4289 37.78953
[31,] -122.4224 37.79024
[32,] -122.4219 37.78849
[33,] -122.4218 37.78744
[34,] -122.4208 37.78289
[35,] -122.4206 37.78196
[36,] -122.4207 37.78185
[37,] -122.4194 37.77542
[38,] -122.4292 37.77418
[39,] -122.4538 37.77102
[40,] -122.4529 37.76637
[41,] -122.4569 37.76587
[42,] -122.4578 37.76601
[43,] -122.4589 37.76626
[44,] -122.4773 37.76545
[45,] -122.5099 37.76409
[46,] -122.5103 37.76400
[47,] -122.5121 37.76365
[48,] -122.5131 37.77078
[49,] -122.5131 37.77121
[50,] -122.5141 37.77783
[51,] -122.5145 37.78083


[[4]]
An object of class "Polygon"
Slot "labpt":
[1] -123.00529   37.69826

Slot "area":
[1] 8.81011e-05

Slot "hole":
[1] FALSE

Slot "ringDir":
[1] 1

Slot "coords":
           [,1]     [,2]
 [1,] -123.0139 37.70036
 [2,] -123.0078 37.69894
 [3,] -123.0075 37.70214
 [4,] -123.0035 37.70440
 [5,] -123.0009 37.70101
 [6,] -122.9988 37.69744
 [7,] -123.0028 37.69274
 [8,] -123.0059 37.69349
 [9,] -123.0075 37.69593
[10,] -123.0128 37.69650
[11,] -123.0139 37.70036



Slot "plotOrder":
[1] 3 4 1 2

Slot "labpt":
[1] -122.46946   37.78285

Slot "ID":
[1] "2"

Slot "area":
[1] 0.002634156



Slot "plotOrder":
[1] 1

Slot "bbox":
         min        max
x -123.01392 -122.41940
y   37.69274   37.83337

Slot "proj4string":
CRS arguments: NA 

我想删除第三个(坐标最多的那个)的DF EXCEPT中的所有多边形,但是我很难弄清楚如何完成。任何帮助都会很棒!

0 个答案:

没有答案