简体   繁体   中英

How to assign coordinates to a data frame from a Spatial polygon dataset

I have a Spatial polygon dataset with 16 features

Deforested_areas_sp
class       : SpatialPolygons 
features    : 16 
extent      : 30.95493, 31.02964, -1.040257, -0.9624111  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0

I want to assign the coordinates of these 16 features to a dataframe which also contains 16 features. Below is dataframe.

Att_table_S01_E031_Mod_df
  ID      AREA LU_1990 LU_2000 LU_2005 CHLU_90_00 CHLU_00_05     Tile       UNIQ_ID D_90_00 D_00_05
1   597  274408.8      11      15      15       1115       1515 S01_E031  S01_E031_597    <NA>    <NA>
2   622  249063.6      11      15      15       1115       1515 S01_E031  S01_E031_622    <NA>    <NA>
3   816   90260.9      11      15      15       1115       1515 S01_E031  S01_E031_816    <NA>    <NA>
4   818  210709.6      11      15      15       1115       1515 S01_E031  S01_E031_818    <NA>    <NA>
5   886  260828.1      11      15      15       1115       1515 S01_E031  S01_E031_886    <NA>    <NA>
6   898 1029736.2      11      15      15       1115       1515 S01_E031  S01_E031_898    <NA>    <NA>
7   935  413891.1      11      15      15       1115       1515 S01_E031  S01_E031_935    <NA>    <NA>
8  1139  272603.0      11      15      15       1115       1515 S01_E031 S01_E031_1139    <NA>    <NA>
9  1169  230945.5      11      15      15       1115       1515 S01_E031 S01_E031_1169    <NA>    <NA>
10 1192  451941.1      11      15      15       1115       1515 S01_E031 S01_E031_1192    <NA>    <NA>
11 1196  270798.2      11      15      15       1115       1515 S01_E031 S01_E031_1196    <NA>    <NA>
12 1203  278951.3      11      15      15       1115       1515 S01_E031 S01_E031_1203    <NA>    <NA>
13 1244  388546.4      11      15      15       1115       1515 S01_E031 S01_E031_1244    <NA>    <NA>
14 1435  105058.9      11      15      15       1115       1515 S01_E031 S01_E031_1435    <NA>    <NA>
15 1436  249060.9      11      12      15       1112       1215 S01_E031 S01_E031_1436    <NA>    <NA>
16 1437  187476.3      11      15      15       1115       1515 S01_E031 S01_E031_1437    <NA>    <NA>
      Sour_90_00    Sour_00_05
1  Modis500_2000 Modis500_2005
2  Modis500_2000 Modis500_2005
3  Modis500_2000 Modis500_2005
4  Modis500_2000 Modis500_2005
5  Modis500_2000 Modis500_2005
6  Modis500_2000 Modis500_2005
7  Modis500_2000 Modis500_2005
8  Modis500_2000 Modis500_2005
9  Modis500_2000 Modis500_2005
10 Modis500_2000 Modis500_2005
11 Modis500_2000 Modis500_2005
12 Modis500_2000 Modis500_2005
13 Modis500_2000 Modis500_2005
14 Modis500_2000 Modis500_2005
15 Modis500_2000 Modis500_2005
16 Modis500_2000 Modis500_2005

However, I have not managed yet to find a way to make the transformation. Help on this would be very appreciated.

Using:

spdf = SpatialPolygonsDataFrame(Sr, data, match.ID = FALSE)

it should create a SpatialPolygonsDataFrame using a SpatialPolygons object Sr for the geometry and a data frame data for the data.

This assumes both are in the same order, otherwise re-order the data frame.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM