【问题标题】:Transform matrix into points based on projection in R基于R中的投影将矩阵转换为点
【发布时间】:2018-12-19 14:40:03
【问题描述】:

我有一个SpatialPolygonsDataFrame,我想将其用作igraph 绘图的底图。我已经成功创建了我的igraph 网络并使用SpatialPolygonsDataFrame 中的centroids 合并了位置。我想以可以绘制在我的底图上的方式转换我的布局坐标,它采用matrix 格式。

我正在使用此代码,但没有得到正确的布局。

long_lat <- SpatialPoints(g_locations, proj4string=CRS("tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs +ellps=airy+towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894"))

transformed_locations <- spTransform(long_lat, CRS('+proj=tmerc')) %>% 
    as.data.frame() %>% 
    as.matrix()

我的问题是,在进行空间变换时,我该如何陈述正确的投影?

以下是我的SpatialPolygonsDataFrame的摘要。你会看到我使用proj4string : 后面的文本作为我的CRC 参数。

local_authority_shp %>% 摘要()

Object of class SpatialPolygonsDataFrame
Coordinates:
       min       max
x 5512.999  655644.8
y 5337.901 1220301.5
Is projected: TRUE 
proj4string :
[+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000
+y_0=-100000 +datum=OSGB36 +units=m +no_defs +ellps=airy
+towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894]
Data attributes:
    objectid        lad17cd             lad17nm             lad17nmw  
 1      :  1   E06000001:  1   Aberdeen City:  1   Abertawe     :  1  
 10     :  1   E06000002:  1   Aberdeenshire:  1   Blaenau Gwent:  1  
 100    :  1   E06000003:  1   Adur         :  1   Bro Morgannwg:  1  
 101    :  1   E06000004:  1   Allerdale    :  1   Caerdydd     :  1  
 102    :  1   E06000005:  1   Amber Valley :  1   Caerffili    :  1  
 103    :  1   E06000006:  1   Angus        :  1   (Other)      : 17  
 (Other):374   (Other)  :374   (Other)      :374   NA's         :358  
     bng_e         bng_n          long              lat       
 126473 :  1   268437 :  2   Min.   :-6.6572   Min.   :49.92  
 199821 :  1   1006584:  1   1st Qu.:-2.5644   1st Qu.:51.46  
 200740 :  1   101094 :  1   Median :-1.3868   Median :52.23  
 212501 :  1   101357 :  1   Mean   :-1.4918   Mean   :52.61  
 226544 :  1   104948 :  1   3rd Qu.:-0.2817   3rd Qu.:53.41  
 227922 :  1   105685 :  1   Max.   : 1.6495   Max.   :60.50  
 (Other):374   (Other):373                                    
   st_areasha          st_lengths      local_authority_shp_centroids
 Min.   :2.904e+06   Min.   :   9250   Length:380                   
 1st Qu.:8.626e+07   1st Qu.:  63953   Class :SpatialPoints         
 Median :2.644e+08   Median : 115284   Mode  :S4                    
 Mean   :6.054e+08   Mean   : 193451                                
 3rd Qu.:6.098e+08   3rd Qu.: 197695                                
 Max.   :2.616e+10   Max.   :5261282  

【问题讨论】:

    标签: r geospatial point projection


    【解决方案1】:

    晚了,但为了后代,一个答案是将矩阵转换为栅格,然后转换为带有raster::rasterToPoints()的点的data.frame

    【讨论】:

      猜你喜欢
      • 2019-03-05
      • 1970-01-01
      • 2019-12-14
      • 2013-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-01
      相关资源
      最近更新 更多