具有R中的多个特征数据集的readOGR .gdb

时间:2015-06-15 17:38:13

标签: r gis gdal rgdal

我正在尝试将地理数据库文件(.gdb)中包含的shapefile读入R.中.gdb包含两个在每个中都有多个要素类的要素数据集。

问题是正在读取两个要素数据集中的一个。 具体来说,我正在将NHD数据集用于所有州ftp://nhdftp.usgs.gov/DataSets/Staged/States/FileGDB/HighResolution/ 在每个状态.gdb是两个特征数据集,'WBD'和'Hydrography'。只读'WBD'。使用ogrListLayers仅返回“WBD”中的图层。如何指定“Hydrography”数据集并访问其中的要素类?

我们非常感谢任何建议。 R版本3.2.0。 OSX v.10.10.3

编辑06/16/15: 当我运行orgListLayers时,它返回:

ogrListLayers('NHDH_VI.gdb')
[1] "ExternalCrosswalk"       "NHDFCode"                "NHDFeatureToMetadata"   
[4] "NHDFlow"                 "NHDFlowlineVAA"          "NHDMetadata"            
[7] "NHDProcessingParameters" "NHDReachCodeMaintenance" "NHDReachCrossReference" 
[10] "NHDSourceCitation"       "NHDStatus"               "NHDVerticalRelationship"
[13] "WBDHU14"                 "WBDHU8"                  "WBDHU2"                 
[16] "WBDHU4"                  "WBDHU6"                  "WBDHU10"                
[19] "WBDHU12"                 "WBDHU16"                 "HYDRO_NET_Junctions" 

21层不同,然后由Mike T和hrbrmstr表达。具体来说,我正在寻找:图层名称:NHDWaterbody。

当我从终端运行ogrinfo -ro NHDH_VI.gdb时。

ERROR 1: Error: Failed to open Geodatabase (This release of the GeoDatabase is either invalid or out of date.)
FAILURE: Unable to open datasource `NHDH_VI.gdb' with the following drivers.
      -> FileGDB
      -> OpenFileGDB
      ...

2 个答案:

答案 0 :(得分:6)

您可能正在使用ESRI File Geodatabase (OpenFileGDB)驱动程序读取该文件。 OGR不保留或使用要素数据集,因此所有要素类都混合在同一个平面命名空间中。在ArcCatalog中查看(例如)NHDH_VI.gdb:

ArcCatalog

然后使用ogrinfo -ro NHDH_VI.gdb

从命令行提示符读取同一文件
INFO: Open of `NHDH_VI.gdb'
      using driver `OpenFileGDB' successful.
1: NHDPoint (Point)
2: NHDFlowline (Multi Line String)
3: NHDLine (Multi Line String)
4: NHDArea (Multi Polygon)
5: NHDWaterbody (Multi Polygon)
6: NHDAreaEventFC (Multi Polygon)
7: NHDLineEventFC (Multi Line String)
8: NHDPointEventFC (Point)
9: WBDLine (Multi Line String)
10: NonContributingDrainageArea (Multi Polygon)
11: NWISBoundary (Multi Line String)
12: NWISDrainageArea (Multi Polygon)
13: WBDHU14 (Multi Polygon)
14: WBDHU8 (Multi Polygon)
15: WBDHU2 (Multi Polygon)
16: WBDHU4 (Multi Polygon)
17: WBDHU6 (Multi Polygon)
18: WBDHU10 (Multi Polygon)
19: WBDHU12 (Multi Polygon)
20: WBDHU16 (Multi Polygon)
21: HYDRO_NET_Junctions (Point)

R中也提供了相同的内容:

> library(rgdal)
> ogrListLayers("NHDH_VI.gdb")
 [1] "NHDPoint"                    "NHDFlowline"                
 [3] "NHDLine"                     "NHDArea"                    
 [5] "NHDWaterbody"                "NHDAreaEventFC"             
 [7] "NHDLineEventFC"              "NHDPointEventFC"            
 [9] "WBDLine"                     "NonContributingDrainageArea"
[11] "NWISBoundary"                "NWISDrainageArea"           
[13] "WBDHU14"                     "WBDHU8"                     
[15] "WBDHU2"                      "WBDHU4"                     
[17] "WBDHU6"                      "WBDHU10"                    
[19] "WBDHU12"                     "WBDHU16"                    
[21] "HYDRO_NET_Junctions"        
attr(,"driver")
[1] "OpenFileGDB"
attr(,"nlayers")
[1] 21

因此,您需要手动将ArcCatalog层次结构中的数据集过滤到可以从OGR中找到的数据集。并非所有类都可用于OGR(例如非空间表,关系类)。

答案 1 :(得分:0)

这不是答案,但需要更多空间来澄清,因为OP没有提供可重复的示例。一旦OP q更完整,我将删除

当我在ogrinfo(其中一个较小的档案馆)上运行NHDH_CT.gdb时,我得到了:

Layer name: NHDPoint
Layer name: NHDFlowline
Layer name: NHDLine
Layer name: NHDArea
Layer name: NHDWaterbody
Layer name: NHDAreaEventFC
Layer name: NHDLineEventFC
Layer name: NHDPointEventFC
Layer name: WBDLine
Layer name: NonContributingDrainageArea
Layer name: NWISBoundary
Layer name: NWISDrainageArea
Layer name: WBDHU14
Layer name: WBDHU8
Layer name: WBDHU2
Layer name: WBDHU4
Layer name: WBDHU6
Layer name: WBDHU10
Layer name: WBDHU12
Layer name: WBDHU16
Layer name: HYDRO_NET_Junctions

匹配:

> ogrListLayers("NHDH_CT.gdb")
 [1] "NHDPoint"                    "NHDFlowline"                 "NHDLine"                    
 [4] "NHDArea"                     "NHDWaterbody"                "NHDAreaEventFC"             
 [7] "NHDLineEventFC"              "NHDPointEventFC"             "WBDLine"                    
[10] "NonContributingDrainageArea" "NWISBoundary"                "NWISDrainageArea"           
[13] "WBDHU14"                     "WBDHU8"                      "WBDHU2"                     
[16] "WBDHU4"                      "WBDHU6"                      "WBDHU10"                    
[19] "WBDHU12"                     "WBDHU16"                     "HYDRO_NET_Junctions"        

你期待看到什么?你的ogrinfo显示什么? (注意:夏威夷给出了相似的输出)。