如何扩展" SpatialPolygonsDataFrame"在一定程度上

时间:2016-02-16 23:31:59

标签: r raster sp

我有一个我想扩展的shapefile(基本上添加了一些NA行和列)。是否有像raster::extend这样的功能?不幸的是,这仅适用于raster个对象。

我可以使用raster::crop裁剪它,SpatialPolygonsDataFramePublic Sub emailList() 'Setting up the Excel variables. Dim olApp As Object Dim olMailItm As Object Dim iCounter As Integer Dim Dest As Variant Dim SDest As String 'Create the Outlook application and the empty email. Set olApp = CreateObject("Outlook.Application") Set olMailItm = olApp.CreateItem(0) 'Using the email, add multiple recipients, using a list of addresses in column A. With olMailItm SDest = "" For iCounter = 1 To WorksheetFunction.CountA(Workbooks("Book1.xls").Sheets(1).Columns(1)) If SDest = "" Then SDest = Range.Cells(iCounter, 1).Value Else SDest = SDest & ";" & Range.Cells(iCounter, 1).Value End If Next iCounter 'Do additional formatting on the BCC and Subject lines, add the body text from the spreadsheet, and send. .BCC = SDest .Subject = "FYI" .Body = ActiveSheet.TextBoxes(1).Text .Send End With 'Clean up the Outlook application. Set olMailItm = Nothing Set olApp = Nothing End Sub 的方法,但我无法找到任何扩展方法。

1 个答案:

答案 0 :(得分:2)

我找到了办法! SpatialPolygons的范围数据似乎存储在名为bbox的插槽中。在插槽内(您可以通过my.polygon@bbox访问),您将找到一个像这样的简单矩阵:

  min max
x -81 -80
y  11  12

只需将另一个矩阵替换为您想要获得的矩阵,就会改变SpatialPolygons的范围。您甚至可以使用其他多边形或栅格的范围来制作矩阵:

my.polygon@bbox <- as.matrix(extent(my.raster))

它不像光栅延伸那么整洁......但它的工作方式相同:) 希望现在还不晚!