如何从位置数据中删除轮廓

时间:2016-02-05 18:11:54

标签: r grid maps

我有海洋物种的位置数据。但是,有些数据属于Land,我想删除它们而不查找它们所属的行(PS2<-PS1[-c(1,2,3),])因为我有一个大数据集。我已经找到了线索但却找不到好的东西。谢谢。

这是我的代码

        require(sp)
        library(maptools)
        require(raster)
        data(wrld_simpl)


        PS<-read.csv('Test.csv')
        PS
   #-----------------
                  lat        lon
1  -32.98000 154.000000
2   36.94625   8.212916
3  -37.81430 -57.479584
4  -19.77236 -40.019028
5  -25.70459 -48.473195
6  -22.47125 -41.859027
7  -28.08153 -48.627082
8   10.56000  39.090000
9   50.50000  50.600000
10  52.50000   5.700000

        PS1 <- subset(PS, !is.na(lon) & !is.na(lat))

        plot(wrld_simpl, bg='azure2', col='khaki', border='#AAAAAA')
        #restore the box around the map
        box()
        #plot points
        points(PS1$lon, PS1$lat, col='orange', pch=20, cex=0.75)
        # plot points again to add a border, for better visibility
        points(PS1$lon, PS1$lat, col='red', cex=0.75)

   The last three data fall on land.

1 个答案:

答案 0 :(得分:1)

这显示了如何使用def time_to_minutes(h,mm): time = h*60 + mm return time def extract_time(time): h=int(time[:-3]) mm=int(time[-2:]) return h,mm def time_between(a,b): first = time_to_minutes(extract_time(a)) return first (您还可以使用%over%功能

over