与我的shapefile关联的proj4字符串是什么?

与我的shapefile关联的proj4字符串是什么?,r,gis,R,Gis,我遵循教程中的“一些简单地图”步骤,尝试从中为新奥尔良的邮政编码地图上色(我使用该链接中新奥尔良2011数据中的.shp文件) 当我尝试像在教程中那样加载文件时,会出现以下错误: nolazip.shp <- readShapePoly("/PathTo/Orleans_ZCTA_2010_SP.shp", proj4string=CRS("+proj=longlat")) Error in validityMethod(as(object, superClass)) : Geogr

我遵循教程中的“一些简单地图”步骤,尝试从中为新奥尔良的邮政编码地图上色(我使用该链接中新奥尔良2011数据中的.shp文件)

当我尝试像在教程中那样加载文件时,会出现以下错误:

nolazip.shp <- readShapePoly("/PathTo/Orleans_ZCTA_2010_SP.shp", proj4string=CRS("+proj=longlat"))
Error in validityMethod(as(object, superClass)) : 
  Geographical CRS given to non-conformant data: 3820725.379655  613426.584024  
我可以通过在readShapePoly命令中省略proj4string参数来导入形状文件,但这不是一个可行的解决方案,因为当我遵循“一些简单贴图”部分(我唯一需要的部分)时,贴图不会出现在绘图窗口中

  • 与我的shapefile关联的proj4字符串是什么?如何将其作为readShapePoly的输入
  • 是否有其他方法可以导入使用此地图制作方法的shapefile?同样,简单地忽略有问题的参数意味着地图不会显示在R studio中的绘图中

  • 我将使用
    readOGR
    解决这个问题,它保留了投影信息,这样您就不必像在上面的问题中那样处理它了。以下是读入后在
    ggplot2
    中绘制的形状文件(下载自)。化妆品可能需要整理一下,但这会让你练习使用
    RColorBrewer
    和磅秤以及其他
    ggplot2
    东西。[编辑-添加缺少的
    aes
    调用
    geom\u多边形
    ]

    # if the packages are not installed, you will have to install and load them.
    install.packages("rgdal")
    install.packages("ggplot2")
    install.packages("scales")
    library(rgdal)
    library(ggplot2)
    library(scales)
    
    require(rgdal)
    require(ggplot2)
    require(scales)
    
    work.dir <- "your_dirname" # your directory
                                         # no trailing slash
    
    orl <- readOGR(work.dir, layer = "Orleans_ZCTA_2010_SP")
    orl.df <- fortify(orl) # ggplot needs data frame, not spatial object
    
    ggplot(data = orl.df, aes(x = long, y = lat, group = group)) +
        geom_polygon(aes(fill = orl.df$group)) +
        coord_equal() +
        theme(legend.position = "none")
    
    #如果未安装软件包,则必须安装并加载它们。
    安装程序包(“rgdal”)
    安装程序包(“ggplot2”)
    安装软件包(“天平”)
    图书馆(rgdal)
    图书馆(GG2)
    图书馆(比例尺)
    需要(rgdal)
    需要(ggplot2)
    需要(天平)
    
    work.dirSlowLearner的答案是解决根本问题的好办法。对于其他人,他们只是来这里问标题问题:

    与我的shapefile关联的proj4字符串是什么?

    area <- rgdal::readOGR(dsn = "path/to/shape.shp")
    
    rgdal::CRSargs(area@proj4string)
    
    区域
    
    area <- rgdal::readOGR(dsn = "path/to/shape.shp")
    
    rgdal::CRSargs(area@proj4string)