如何在R中为.shp多边形文件设置CRS。

问题描述 投票:0回答:1

我对在R中处理地理空间数据非常陌生。我有一个在我的研究区域的几个象限的形状文件,我根据 "象限ID "进行分类。我能够使用ggplot和sf包很好地显示我的数据,但是,我的数据似乎没有正确显示。当检查形状文件中的任何空间数据信息时,似乎没有。

> proj4string(quads)
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘proj4string’ for signature ‘"sf"’

我希望x& y实验室是以小数点为单位。我试着给我的文件分配一个CRS,但是,我得到这个错误。

> proj4string(quads) <- CRS("+proj=longlat +datum=WGS84")
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘proj4string<-’ for signature ‘"sf", "CRS"’

我也试过使用EPSG代码,但还是得到一个错误。

> proj4string(quads) <- CRS("+init=epsg:4979")
Error in CRS("+init=epsg:4979") : no options found in 'init' file

我在网上搜索了这些错误的含义 但似乎对处理空间数据的整体过程感到困惑 我遇到的所有解决方案都不适合我。如果有人有任何见解,我可以使这个工作,我真的很感激它! 下面是我的完整代码,我还附上了我的绘图目前的截图,它很好,但x轴和y轴对应的是观测数据的几何形状,我希望它们是文件的x和y范围。

enter image description here

quads <- quads %>%  #assigning quadID values to my .shp file
  mutate(quadID = case_when(IDR_ID == 424 ~ "ZOI",
                            IDR_ID == 423 |between(IDR_ID, 425, 433) ~ "Adjacent",
                            between (IDR_ID, 365, 422) ~ "Transit",

                            TRUE ~ ""))
proj4string(quads) #attempting to look for a crs (I know there are none, but this is to check)
proj4string(quads) <- CRS("+proj=longlat +datum=WGS84") #attempting to assign a crs to my .shp

Fig1 <- ggplot(data = quads) +
  geom_sf(aes(fill = quadID)) +
  scale_fill_manual(values = c("#eefbfb",
                                "#6b8c42", 
                                "#70b2ae", 
                                "#d65a31")) +
  theme_bw()
Fig1

这是我的.shp df的样本

> head(SampleData)
Simple feature collection with 6 features and 3 fields
geometry type:  MULTIPOLYGON
dimension:      XY
bbox:           xmin: 480283.2 ymin: 5206810 xmax: 514635.2 ymax: 5450114
CRS:            NA
    IDR_ID ORIGFQ                       geometry   quadID
144    144     52 MULTIPOLYGON (((509774.1 54...         
430    430    285 MULTIPOLYGON (((507829.6 52... Adjacent
183    183    152 MULTIPOLYGON (((482551.7 53...         
45      45    391 MULTIPOLYGON (((481579.4 54...         
139    139     80 MULTIPOLYGON (((480283.2 54...         
195    195     21 MULTIPOLYGON (((501996.2 53...    
> dput(SampleData)
structure(list(IDR_ID = c(144, 430, 183, 45, 139, 195, 227, 5, 
162, 174), ORIGFQ = c(52, 285, 152, 391, 80, 21, 159, 383, 138, 
145), geometry = structure(list(structure(list(list(structure(c(509774.0625, 
510098.15625, 510422.21875, 510746.28125, 511070.375, 511394.4375, 
511718.53125, 512042.59375, 512366.6875, 512690.75, 513014.8125, 
513338.90625, 513662.96875, 513987.0625, 514311.125, 514635.21875, 
514635.21875, 514635.21875, 514635.21875, 514635.21875, 514635.21875, 
514635.21875, 514311.125, 513987.0625, 513662.96875, 513338.90625, 
513014.8125, 512690.75, 512366.6875, 512042.59375, 511718.53125, 
511394.4375, 511070.375, 510746.28125, 510422.21875, 510098.15625, 
509774.0625, 509774.0625, 509774.0625, 509774.0625, 509774.0625, 
509774.0625, 509774.0625, 5407728, 5407728, 5407728, 5407728, 
5407728, 5407728, 5407728, 5407728, 5407728, 5407728, 5407728, 
5407728, 5407728, 5407728, 5407728, 5407728, 5407177.5, 5406627, 
5406076.5, 5405526, 5404975.5, 5404425.5, 5404425.5, 5404425.5, 
5404425.5, 5404425.5, 5404425.5, 5404425.5, 5404425.5, 5404425.5, 
5404425.5, 5404425.5, 5404425.5, 5404425.5, 5404425.5, 5404425.5, 
5404425.5, 5404975.5, 5405526, 5406076.5, 5406627, 5407177.5, 
5407728), .Dim = c(43L, 2L)))), class = c("XY", "MULTIPOLYGON", 
"sfg")), structure(list(list(structure(c(507829.625, 508153.6875, 
508153.6875, 507829.625, 507829.625, 5211214, 5211214, 5210663.5, 
5210663.5, 5211214), .Dim = c(5L, 2L))), list(structure(c(511718.53125, 
512042.59375, 512042.59375, 512042.59375, 512042.59375, 512042.59375, 
512042.59375, 512042.59375, 512042.59375, 512042.59375, 511718.53125, 
511718.53125, 511394.4375, 511394.4375, 511070.375, 510746.28125, 
510746.28125, 510422.21875, 510098.15625, 510098.15625, 509774.0625, 
509450, 509125.90625, 508801.84375, 508801.84375, 508801.84375, 
508477.75, 508153.6875, 507829.625, 507505.53125, 507505.53125, 
507181.46875, 506857.375, 506857.375, 506857.375, 507181.46875, 
507181.46875, 507505.53125, 507505.53125, 507829.625, 507829.625, 
508153.6875, 508153.6875, 508153.6875, 507829.625, 507829.625, 
507829.625, 507829.625, 507505.53125, 507505.53125, 507505.53125, 
507505.53125, 507505.53125, 507829.625, 507829.625, 507829.625, 
507829.625, 507505.53125, 507505.53125, 507505.53125, 507505.53125, 
507181.46875, 507181.46875, 507181.46875, 507181.46875, 507181.46875, 
507181.46875, 506857.375, 506533.3125, 506533.3125, 506857.375, 
506857.375, 506857.375, 506857.375, 506857.375, 506857.375, 506857.375, 
506857.375, 506857.375, 506533.3125, 506533.3125, 506533.3125, 
506209.21875, 505885.15625, 505885.15625, 505561.09375, 505561.09375, 
505237, 505237, 505237, 505237, 505237, 505237, 505561.09375, 
505561.09375, 505885.15625, 505885.15625, 505885.15625, 505561.09375, 
505561.09375, 505561.09375, 505561.09375, 505561.09375, 505237, 
504912.9375, 504912.9375, 504588.84375, 504588.84375, 504264.78125, 
504264.78125, 504264.78125, 504588.84375, 504588.84375, 504588.84375, 
504588.84375, 504264.78125, 503940.6875, 503940.6875, 503940.6875, 
503616.625, 503292.53125, 502968.46875, 502644.40625, 502644.40625, 
502320.3125, 501996.25, 501996.25, 501672.15625, 501348.09375, 
501024, 501024, 500699.9375, 500699.9375, 500375.875, 500051.78125, 
500051.78125, 499727.71875, 499403.625, 499403.625, 499727.71875, 
499727.71875, 500051.78125, 500375.875, 500699.9375, 500699.9375, 
501024, 501024, 501024, 501024, 500699.9375, 500699.9375, 500375.875, 
500375.875, 500051.78125, 499727.71875, 499727.71875, 499403.625, 
499079.5625, 499079.5625, 499079.5625, 499079.5625, 499079.5625, 
499403.625, 499403.625, 499727.71875, 500051.78125, 500375.875, 
500375.875, 500699.9375, 501024, 501024, 501024, 501348.09375, 
501348.09375, 501672.15625, 501996.25, 501996.25, 502320.3125, 
502644.40625, 502968.46875, 503292.53125, 503292.53125, 502968.46875, 
502968.46875, 502968.46875, 502968.46875, 502968.46875, 503292.53125, 
503292.53125, 503616.625, 503616.625, 503940.6875, 503940.6875, 
504264.78125, 504588.84375, 504912.9375, 504912.9375, 505237, 
505561.09375, 505561.09375, 505885.15625, 505885.15625, 505885.15625, 
506209.21875, 506209.21875, 506209.21875, 505885.15625, 505561.09375, 
505237, 504912.9375, 504912.9375, 504912.9375, 504588.84375, 
504588.84375, 504912.9375, 505237, 505561.09375, 505885.15625, 
506209.21875, 506209.21875, 506533.3125, 506533.3125, 506857.375, 
507181.46875, 507181.46875, 507505.53125, 507505.53125, 507829.625, 
507829.625, 508153.6875, 508153.6875, 508153.6875, 507829.625, 
507829.625, 507505.53125, 507505.53125, 507829.625, 507829.625, 
508153.6875, 508477.75, 508801.84375, 508801.84375, 508801.84375, 
509125.90625, 509125.90625, 509125.90625, 509125.90625, 509125.90625, 
509450, 509450, 509774.0625, 510098.15625, 510098.15625, 510422.21875, 
510422.21875, 510746.28125, 511070.375, 511070.375, 511070.375, 
511394.4375, 511394.4375, 511718.53125, 511718.53125, 511718.53125, 
511718.53125, 5227728, 5227728, 5227177.5, 5226627, 5226076.5, 
5225526, 5224975.5, 5224425, 5223874.5, 5223324.5, 5223324.5, 
5222774, 5222774, 5223324.5, 5223324.5, 5223324.5, 5222774, 5222774, 
5222774, 5222223.5, 5222223.5, 5222223.5, 5222223.5, 5222223.5, 
5221673, 5221122.5, 5221122.5, 5221122.5, 5221122.5, 5221122.5, 
5220572, 5220572, 5220572, 5220021.5, 5219471, 5219471, 5218920.5, 
5218920.5, 5218370, 5218370, 5217819.5, 5217819.5, 5217269, 5216719, 
5216719, 5216168.5, 5215618, 5215067.5, 5215067.5, 5214517, 5213966.5, 
5213416, 5212865.5, 5212865.5, 5212315, 5211764.5, 5211214, 5211214, 
5210663.5, 5210113.5, 5209563, 5209563, 5209012.5, 5208462, 5207911.5, 
5207361, 5206810.5, 5206810.5, 5206810.5, 5207361, 5207361, 5207911.5, 
5208462, 5209012.5, 5209563, 5210113.5, 5210663.5, 5211214, 5211764.5, 
5211764.5, 5212315, 5212865.5, 5212865.5, 5212865.5, 5213416, 
5213416, 5213966.5, 5213966.5, 5214517, 5215067.5, 5215618, 5216168.5, 
5216719, 5216719, 5217269, 5217269, 5217819.5, 5218370, 5218370, 
5218920.5, 5219471, 5220021.5, 5220572, 5220572, 5220572, 5220021.5, 
5220021.5, 5219471, 5219471, 5218920.5, 5218370, 5218370, 5217819.5, 
5217269, 5216719, 5216719, 5216719, 5216168.5, 5215618, 5215618, 
5215618, 5215618, 5215618, 5215067.5, 5215067.5, 5215067.5, 5214517, 
5214517, 5214517, 5214517, 5213966.5, 5213966.5, 5213416, 5213416, 
5213416, 5212865.5, 5212865.5, 5212865.5, 5212315, 5212315, 5211764.5, 
5211764.5, 5211764.5, 5211764.5, 5211214, 5211214, 5210663.5, 
5210113.5, 5209563, 5209563, 5210113.5, 5210113.5, 5210663.5, 
5210663.5, 5210663.5, 5211214, 5211214, 5211214, 5211764.5, 5212315, 
5212865.5, 5213416, 5213416, 5213966.5, 5213966.5, 5213966.5, 
5213966.5, 5214517, 5214517, 5214517, 5215067.5, 5215618, 5215618, 
5216168.5, 5216168.5, 5216168.5, 5216719, 5216719, 5216719, 5216719, 
5216719, 5217269, 5217269, 5217819.5, 5218370, 5218920.5, 5219471, 
5219471, 5220021.5, 5220021.5, 5220572, 5220572, 5221122.5, 5221122.5, 
5221122.5, 5221122.5, 5221673, 5221673, 5221673, 5222223.5, 5222223.5, 
5222774, 5223324.5, 5223324.5, 5223874.5, 5224425, 5224425, 5224425, 
5224425, 5224425, 5224975.5, 5225526, 5225526, 5226076.5, 5226076.5, 
5226076.5, 5226076.5, 5226076.5, 5226076.5, 5225526, 5225526, 
5224975.5, 5224975.5, 5224975.5, 5224425, 5224425, 5223874.5, 
5223874.5, 5223324.5, 5223324.5, 5223874.5, 5224425, 5224425, 
5224975.5, 5224975.5, 5225526, 5225526, 5226076.5, 5226076.5, 
5226076.5, 5226076.5, 5225526, 5224975.5, 5224975.5, 5224425, 
5223874.5, 5223324.5, 5222774, 5222774, 5223324.5, 5223324.5, 
5223324.5, 5223874.5, 5223874.5, 5224425, 5224425, 5224425, 5224975.5, 
5225526, 5225526, 5226076.5, 5226076.5, 5226627, 5227177.5, 5227728
), .Dim = c(265L, 2L)))), class = c("XY", "MULTIPOLYGON", "sfg"
)), structure(list(list(structure(c(482551.6875, 482875.75, 483199.84375, 
483523.90625, 483847.96875, 484172.0625, 484496.125, 484820.21875, 
485144.28125, 485468.375, 485792.4375, 486116.53125, 486440.59375, 
486764.65625, 487088.75, 487412.8125, 487736.90625, 488060.96875, 
488385.0625, 488709.125, 489033.1875, 489033.1875, 489033.1875, 
489033.1875, 489033.1875, 489033.1875, 489033.1875, 489033.1875, 
489033.1875, 489033.1875, 488709.125, 488385.0625, 488060.96875, 
487736.90625, 487412.8125, 487088.75, 486764.65625, 486440.59375, 
486116.53125, 485792.4375, 485468.375, 485144.28125, 484820.21875, 
484496.125, 484172.0625, 483847.96875, 483523.90625, 483199.84375, 
482875.75, 482551.6875, 482551.6875, 482551.6875, 482551.6875, 
482551.6875, 482551.6875, 482551.6875, 482551.6875, 482551.6875, 
482551.6875, 5370297, 5370297, 5370297, 5370297, 5370297, 5370297, 
5370297, 5370297, 5370297, 5370297, 5370297, 5370297, 5370297, 
5370297, 5370297, 5370297, 5370297, 5370297, 5370297, 5370297, 
5370297, 5369746.5, 5369196, 5368645.5, 5368095, 5367544.5, 5366994, 
5366443.5, 5365893, 5365342.5, 5365342.5, 5365342.5, 5365342.5, 
5365342.5, 5365342.5, 5365342.5, 5365342.5, 5365342.5, 5365342.5, 
5365342.5, 5365342.5, 5365342.5, 5365342.5, 5365342.5, 5365342.5, 
5365342.5, 5365342.5, 5365342.5, 5365342.5, 5365342.5, 5365893, 
5366443.5, 5366994, 5367544.5, 5368095, 5368645.5, 5369196, 5369746.5, 
5370297), .Dim = c(59L, 2L)))), class = c("XY", "MULTIPOLYGON", 
"sfg")), structure(list(list(structure(c(481579.4375, 481903.53125, 
482227.59375, 482551.6875, 482875.75, 483199.84375, 483523.90625, 
483847.96875, 484172.0625, 484496.125, 484820.21875, 485144.28125, 
485468.375, 485468.375, 485144.28125, 485144.28125, 484820.21875, 
484820.21875, 484820.21875, 485144.28125, 485468.375, 485792.4375, 
485792.4375, 486116.53125, 486440.59375, 486440.59375, 486116.53125, 
486116.53125, 485792.4375, 485468.375, 485468.375, 485144.28125, 
484820.21875, 484496.125, 484172.0625, 483847.96875, 483523.90625, 
483199.84375, 482875.75, 482551.6875, 482227.59375, 481903.53125, 
481579.4375, 481579.4375, 481579.4375, 481579.4375, 481579.4375, 
481579.4375, 481579.4375, 481579.4375, 481579.4375, 5450113.5, 
5450113.5, 5450113.5, 5450113.5, 5450113.5, 5450113.5, 5450113.5, 
5450113.5, 5450113.5, 5450113.5, 5450113.5, 5450113.5, 5450113.5, 
5449563, 5449563, 5449012.5, 5449012.5, 5448462, 5447911.5, 5447911.5, 
5447911.5, 5447911.5, 5447361, 5447361, 5447361, 5446810.5, 5446810.5, 
5446260, 5446260, 5446260, 5445709.5, 5445709.5, 5445709.5, 5445709.5, 
5445709.5, 5445709.5, 5445709.5, 5445709.5, 5445709.5, 5445709.5, 
5445709.5, 5445709.5, 5445709.5, 5446260, 5446810.5, 5447361, 
5447911.5, 5448462, 5449012.5, 5449563, 5450113.5), .Dim = c(51L, 
2L)))), class = c("XY", "MULTIPOLYGON", "sfg")), structure(list(
    list(structure(c(480283.15625, 480607.21875, 480607.21875, 
    480283.15625, 480283.15625, 5412131.5, 5412131.5, 5411581, 
    5411581, 5412131.5), .Dim = c(5L, 2L))), list(structure(c(481579.4375, 
    481903.53125, 482227.59375, 482551.6875, 482875.75, 483199.84375, 
    483523.90625, 483847.96875, 484172.0625, 484496.125, 484820.21875, 
    485144.28125, 485468.375, 485792.4375, 486116.53125, 486116.53125, 
    486116.53125, 486116.53125, 486116.53125, 486116.53125, 486116.53125, 
    486116.53125, 486116.53125, 486116.53125, 485792.4375, 485792.4375, 
    485468.375, 485144.28125, 484820.21875, 484820.21875, 484496.125, 
    484172.0625, 484172.0625, 483847.96875, 483523.90625, 483199.84375, 
    483199.84375, 483523.90625, 483523.90625, 483199.84375, 482875.75, 
    482551.6875, 482227.59375, 482227.59375, 481903.53125, 481579.4375, 
    481579.4375, 481903.53125, 481903.53125, 481903.53125, 481903.53125, 
    481579.4375, 481579.4375, 481255.375, 480931.3125, 480607.21875, 
    480607.21875, 480931.3125, 481255.375, 481579.4375, 481579.4375, 
    5412131.5, 5412131.5, 5412131.5, 5412131.5, 5412131.5, 5412131.5, 
    5412131.5, 5412131.5, 5412131.5, 5412131.5, 5412131.5, 5412131.5, 
    5412131.5, 5412131.5, 5412131.5, 5411581, 5411031, 5410480.5, 
    5409930, 5409379.5, 5408829, 5408278.5, 5407728, 5407177.5, 
    5407177.5, 5407728, 5407728, 5407728, 5407728, 5408278.5, 
    5408278.5, 5408278.5, 5408829, 5408829, 5408829, 5408829, 
    5408278.5, 5408278.5, 5407728, 5407728, 5407728, 5407728, 
    5407728, 5408278.5, 5408278.5, 5408278.5, 5408829, 5408829, 
    5409379.5, 5409930, 5410480.5, 5410480.5, 5411031, 5411031, 
    5411031, 5411031, 5411581, 5411581, 5411581, 5411581, 5412131.5
    ), .Dim = c(61L, 2L)))), class = c("XY", "MULTIPOLYGON", 
"sfg")), structure(list(list(structure(c(501996.25, 502320.3125, 
502644.40625, 502968.46875, 503292.53125, 503616.625, 503940.6875, 
504264.78125, 504588.84375, 504912.9375, 505237, 505561.09375, 
505885.15625, 506209.21875, 506533.3125, 506857.375, 507181.46875, 
507505.53125, 507829.625, 508153.6875, 508477.75, 508801.84375, 
509125.90625, 509450, 509774.0625, 509774.0625, 509774.0625, 
509774.0625, 509774.0625, 509774.0625, 509450, 509450, 509125.90625, 
508801.84375, 508801.84375, 508477.75, 508477.75, 508153.6875, 
507829.625, 507829.625, 507505.53125, 507181.46875, 506857.375, 
506533.3125, 506533.3125, 506209.21875, 505885.15625, 505561.09375, 
505237, 504912.9375, 504588.84375, 504264.78125, 503940.6875, 
503940.6875, 504264.78125, 504264.78125, 503940.6875, 503940.6875, 
503616.625, 503616.625, 503292.53125, 503292.53125, 502968.46875, 
502644.40625, 502320.3125, 501996.25, 501996.25, 501996.25, 501996.25, 
501996.25, 501996.25, 501996.25, 501996.25, 501996.25, 501996.25, 
5397820, 5397820, 5397820, 5397820, 5397820, 5397820, 5397820, 
5397820, 5397820, 5397820, 5397820, 5397820, 5397820, 5397820, 
5397820, 5397820, 5397820, 5397820, 5397820, 5397820, 5397820, 
5397820, 5397820, 5397820, 5397820, 5397269.5, 5396719, 5396168.5, 
5395618, 5395067.5, 5395067.5, 5395618, 5395618, 5395618, 5395067.5, 
5395067.5, 5395618, 5395618, 5395618, 5396168.5, 5396168.5, 5396168.5, 
5396168.5, 5396168.5, 5395618, 5395618, 5395618, 5395618, 5395618, 
5395618, 5395618, 5395618, 5395618, 5395067.5, 5395067.5, 5394517, 
5394517, 5393966.5, 5393966.5, 5393416, 5393416, 5392865.5, 5392865.5, 
5392865.5, 5392865.5, 5392865.5, 5393416, 5393966.5, 5394517, 
5395067.5, 5395618, 5396168.5, 5396719, 5397269.5, 5397820), .Dim = c(75L, 
2L)))), class = c("XY", "MULTIPOLYGON", "sfg")), structure(list(
    list(structure(c(499403.625, 499727.71875, 500051.78125, 
    500375.875, 500375.875, 500375.875, 500375.875, 500375.875, 
    500375.875, 500375.875, 500375.875, 500375.875, 500375.875, 
    500051.78125, 499727.71875, 499403.625, 499079.5625, 498755.46875, 
    498431.40625, 498107.34375, 497783.25, 497459.1875, 497135.09375, 
    496811.03125, 496486.9375, 496162.875, 495838.8125, 495514.71875, 
    495190.65625, 495190.65625, 495190.65625, 495190.65625, 495190.65625, 
    495190.65625, 495190.65625, 495190.65625, 495190.65625, 495514.71875, 
    495838.8125, 496162.875, 496486.9375, 496811.03125, 497135.09375, 
    497459.1875, 497783.25, 498107.34375, 498431.40625, 498755.46875, 
    499079.5625, 499403.625, 499403.625, 5364242, 5364242, 5364242, 
    5364242, 5363691.5, 5363141, 5362590.5, 5362040, 5361489.5, 
    5360939, 5360388.5, 5359838, 5359287.5, 5359287.5, 5359287.5, 
    5359287.5, 5359287.5, 5359287.5, 5359287.5, 5359287.5, 5359287.5, 
    5359287.5, 5359287.5, 5359287.5, 5359287.5, 5359287.5, 5359287.5, 
    5359287.5, 5359287.5, 5359838, 5360388.5, 5360939, 5361489.5, 
    5362040, 5362590.5, 5363141, 5363691.5, 5363691.5, 5363691.5, 
    5363691.5, 5363691.5, 5363691.5, 5363691.5, 5363691.5, 5363691.5, 
    5363691.5, 5363691.5, 5363691.5, 5363691.5, 5363691.5, 5364242
    ), .Dim = c(51L, 2L)))), class = c("XY", "MULTIPOLYGON", 
"sfg")), structure(list(list(structure(c(429079.125, 429403.21875, 
429727.28125, 430051.34375, 430375.4375, 430699.5, 431023.59375, 
431347.65625, 431671.75, 431995.8125, 432319.90625, 432643.96875, 
432968.03125, 433292.125, 433616.1875, 433940.28125, 433940.28125, 
433940.28125, 433940.28125, 433940.28125, 433940.28125, 433940.28125, 
433940.28125, 433940.28125, 433616.1875, 433292.125, 432968.03125, 
432643.96875, 432319.90625, 431995.8125, 431671.75, 431347.65625, 
431023.59375, 430699.5, 430375.4375, 430051.34375, 429727.28125, 
429403.21875, 429079.125, 429079.125, 429079.125, 429079.125, 
429079.125, 429079.125, 429079.125, 429079.125, 429079.125, 5464976, 
5464976, 5464976, 5464976, 5464976, 5464976, 5464976, 5464976, 
5464976, 5464976, 5464976, 5464976, 5464976, 5464976, 5464976, 
5464976, 5464425.5, 5463875, 5463324.5, 5462774, 5462223.5, 5461673, 
5461122.5, 5460572, 5460572, 5460572, 5460572, 5460572, 5460572, 
5460572, 5460572, 5460572, 5460572, 5460572, 5460572, 5460572, 
5460572, 5460572, 5460572, 5461122.5, 5461673, 5462223.5, 5462774, 
5463324.5, 5463875, 5464425.5, 5464976), .Dim = c(47L, 2L)))), class = c("XY", 
"MULTIPOLYGON", "sfg")), structure(list(list(structure(c(475097.9375, 
475422, 475746.09375, 476070.15625, 476394.21875, 476718.3125, 
477042.375, 477366.46875, 477690.53125, 478014.625, 478338.6875, 
478338.6875, 478662.78125, 478662.78125, 478986.84375, 479310.90625, 
479635, 479635, 479959.0625, 480283.15625, 480607.21875, 480607.21875, 
480931.3125, 481255.375, 481255.375, 481579.4375, 481903.53125, 
481903.53125, 482227.59375, 482551.6875, 482875.75, 482875.75, 
482551.6875, 482227.59375, 481903.53125, 481579.4375, 481255.375, 
480931.3125, 480607.21875, 480283.15625, 479959.0625, 479635, 
479310.90625, 478986.84375, 478662.78125, 478662.78125, 478662.78125, 
478662.78125, 478338.6875, 478014.625, 478014.625, 477690.53125, 
477690.53125, 477366.46875, 477042.375, 477042.375, 476718.3125, 
476394.21875, 476070.15625, 475746.09375, 475746.09375, 476070.15625, 
476070.15625, 475746.09375, 475746.09375, 475422, 475097.9375, 
474773.84375, 474773.84375, 474773.84375, 474773.84375, 474773.84375, 
474773.84375, 474773.84375, 474773.84375, 475097.9375, 475097.9375, 
475097.9375, 475097.9375, 5401673, 5401673, 5401673, 5401673, 
5401673, 5401673, 5401673, 5401673, 5401673, 5401673, 5401673, 
5401122.5, 5401122.5, 5400572, 5400572, 5400572, 5400572, 5400021.5, 
5400021.5, 5400021.5, 5400021.5, 5399471, 5399471, 5399471, 5398920.5, 
5398920.5, 5398920.5, 5398370, 5398370, 5398370, 5398370, 5397820, 
5397820, 5397820, 5397820, 5397820, 5397820, 5397820, 5397820, 
5397820, 5397820, 5397820, 5397820, 5397820, 5397820, 5397269.5, 
5396719, 5396168.5, 5396168.5, 5396168.5, 5396719, 5396719, 5397269.5, 
5397269.5, 5397269.5, 5397820, 5397820, 5397820, 5397820, 5397820, 
5397269.5, 5397269.5, 5396719, 5396719, 5396168.5, 5396168.5, 
5396168.5, 5396168.5, 5396719, 5397269.5, 5397820, 5398370, 5398920.5, 
5399471, 5400021.5, 5400021.5, 5400572, 5401122.5, 5401673), .Dim = c(79L, 
2L)))), class = c("XY", "MULTIPOLYGON", "sfg")), structure(list(
    list(structure(c(475097.9375, 475422, 475746.09375, 476070.15625, 
    476394.21875, 476718.3125, 477042.375, 477366.46875, 477690.53125, 
    478014.625, 478338.6875, 478662.78125, 478986.84375, 479310.90625, 
    479635, 479959.0625, 479959.0625, 479959.0625, 479959.0625, 
    479959.0625, 479959.0625, 479959.0625, 480283.15625, 480283.15625, 
    480283.15625, 480283.15625, 480283.15625, 479959.0625, 479959.0625, 
    479635, 479310.90625, 479310.90625, 478986.84375, 478662.78125, 
    478662.78125, 478338.6875, 478338.6875, 478014.625, 477690.53125, 
    477690.53125, 477366.46875, 477366.46875, 477042.375, 477042.375, 
    476718.3125, 476718.3125, 476394.21875, 476394.21875, 476070.15625, 
    475746.09375, 475746.09375, 475422, 475422, 475097.9375, 
    475097.9375, 5389012.5, 5389012.5, 5389012.5, 5389012.5, 
    5389012.5, 5389012.5, 5389012.5, 5389012.5, 5389012.5, 5389012.5, 
    5389012.5, 5389012.5, 5389012.5, 5389012.5, 5389012.5, 5389012.5, 
    5388462, 5387911.5, 5387361, 5386810.5, 5386260, 5385709.5, 
    5385709.5, 5385159, 5384609, 5384058.5, 5383508, 5383508, 
    5384058.5, 5384058.5, 5384058.5, 5384609, 5384609, 5384609, 
    5385159, 5385159, 5384609, 5384609, 5384609, 5385159, 5385159, 
    5385709.5, 5385709.5, 5386260, 5386260, 5386810.5, 5386810.5, 
    5387361, 5387361, 5387361, 5387911.5, 5387911.5, 5388462, 
    5388462, 5389012.5), .Dim = c(55L, 2L)))), class = c("XY", 
"MULTIPOLYGON", "sfg"))), class = c("sfc_MULTIPOLYGON", "sfc"
), precision = 0, bbox = structure(c(xmin = 429079.125, ymin = 5206810.5, 
xmax = 514635.21875, ymax = 5464976), class = "bbox"), crs = structure(list(
    input = NA_character_, wkt = NA_character_), class = "crs"), n_empty = 0L), 
    quadID = c("", "Adjacent", "", "", "", "", "", "", "", ""
    )), sf_column = "geometry", agr = structure(c(IDR_ID = NA_integer_, 
ORIGFQ = NA_integer_, quadID = NA_integer_), .Label = c("constant", 
"aggregate", "identity"), class = "factor"), row.names = c(144L, 
430L, 183L, 45L, 139L, 195L, 227L, 5L, 162L, 174L), class = c("sf", 
"data.frame"))

谢谢您的帮助!我是一个在R中处理地理空间数据的新手。

r ggplot2 geospatial sf map-projections
1个回答
1
投票

由于你使用 sf您可以直接使用 EPSG 代码来定义CRS。

要定义一个CRS。

library(sf)
myshapefile  <- myshapefile %>% st_set_crs(4979)

您也可以在读取shapefile时使用 st_read 如果没有检测到)。

st_read("myshapefile.shp", crs = 4979)

要重新投射数据,使用 st_transform例如: st_transform(4326)

© www.soinside.com 2019 - 2024. All rights reserved.