我使用的是GDAL 2.0.2,它已“附带”了FDGB支持,并且没有第三方FGDB驱动程序来研究这些东西。测试环境是Debian Jessie 64位。
简而言之,似乎“图层” Zone9_2014_01_Vessel
包含纯属性数据,而图层Zone9_2014_01_Broadcast
包含位置数据。您可以通过系统调用以及GDB与shapefile容器的对话(答案的最后一个脚本)在R中使用变通办法。
这是调查步骤:
$ mkdir ~/dev.d/gis-se.d/gdb
$ cd ~/dev.d/gis-se.d/gdb
$ wget https://coast.noaa.gov/htdata/CMSP/AISDataHandler/2014/01/Zone9_2014_01.zip
$ unzip Zone9_2014_01.zip
$ ogrinfo Zone9_2014_01.gdb Zone9_2014_01_Vessel | head -20
Had to open data source read-only.
INFO: Open of `Zone9_2014_01.gdb'
using driver `OpenFileGDB' successful.
Layer name: Zone9_2014_01_Vessel
Geometry: None <---------------------------- HERE
Feature Count: 1282
Layer SRS WKT:
(unknown)
FID Column = OID
MMSI: Integer (0.0)
IMO: Integer (0.0)
CallSign: String (255.0)
Name: String (255.0)
VesselType: Integer (0.0)
Length: Integer (0.0)
Width: Integer (0.0)
DimensionComponents: String (255.0)
OGRFeature(Zone9_2014_01_Vessel):1
MMSI (Integer) = 367603345
如您所见,该字段Geometry
设置为None
。您可以使用将数据转换为形状文件,ogr2ogr
并且仅获取dbase属性文件:
$ ogr2ogr -f 'ESRI SHAPEFILE' test Zone9_2014_01.gdb Zone9_2014_01_Vessel
$ ls test
Zone9_2014_01_Vessel.dbf
可以在图层中找到几何形状(位置)Zone9_2014_01_Broadcast
。
$ ogr2ogr -f 'ESRI SHAPEFILE' test Zone9_2014_01.gdb
$ ls test
Zone9_2014_01_Broadcast.dbf
Zone9_2014_01_Broadcast.shp
Zone9_2014_01_Broadcast.prj
Zone9_2014_01_Broadcast.shx
Zone9_2014_01_Vessel.dbf
Zone9_2014_01_Voyage.dbf
根据AIS消息协议,不包含位置数据的船舶和航行。
这是R中的完整解决方法,它使用系统调用来让GDB进行shapefile对话,并使用包foreign
来读取dbf:
# Load module to get readOGR
require('rgdal');
# Load module to get read.dbf
require('foreign');
# goto the directory with the GDB stuff
setwd('~/dev.d/gis-se.d/gdb')
# Conversation to a shapefile container
system("ogr2ogr -f 'ESRI SHAPEFILE' test Zone9_2014_01.gdb")
# read the vessels
vessel <- read.dbf('test/Zone9_2014_01_Vessel.dbf');
# read hte voyage data
voyage <- read.dbf('test/Zone9_2014_01_Voyage.dbf');
# read the geometries in broad cast
broadcast <- readOGR('test/Zone9_2014_01_Broadcast.shp','Zone9_2014_01_Broadcast')
OGR data source with driver: ESRI Shapefile
Source: "test/Zone9_2014_01_Broadcast.shp", layer: "Zone9_2014_01_Broadcast"
with 1639274 features
It has 10 fields
# is vessel OK?
head(vessel)
MMSI IMO CallSign Name VesselType Length Width DimensionC
1 367603345 NA <NA> <NA> 50 20 6 7,13,3,3
2 563000574 NA <NA> <NA> 70 276 40 188,88,20,20
3 367449580 NA <NA> <NA> 31 28 10 9,19,5,5
4 367302503 NA <NA> <NA> 31 20 8 8,12,4,4
5 304003909 NA <NA> <NA> 71 222 32 174,48,21,11
6 210080027 NA <NA> <NA> 71 294 32 222,72,22,10
# is voyage OK?
head(voyage)
VoyageID Destinatio Cargo Draught ETA StartTime EndTime MMSI
1 12 KAKE 50 20 <NA> 2014-01-01 <NA> 367603345
2 23 YOKOHAMA 70 125 2014-01-11 2014-01-01 2014-01-30 563000574
3 38 KETCHIKAN AK 31 40 2014-11-12 2014-01-01 <NA> 367449580
4 52 CLARENCE STRAIT LOGS 31 30 2014-09-12 2014-01-01 <NA> 367302503
5 62 JP TYO 71 90 2014-01-13 2014-01-01 2014-01-31 304003909
6 47 VOSTOCHNYY 71 106 2014-01-13 2014-01-01 <NA> 210080027