Closed josephramsay closed 11 years ago
Works for both NZGD2000 (EPSG:4167) and RSRGD2000(EPSG:4764):
ogr2ogr --config FGDB_BULK_LOAD YES -f "FileGDB" antarctic_geodetic_marks.gdb wfs:"http://wfs.data.linz.govt.nz/API-KEY/v/x789/wfs" -nln antarctic_geodetic_marks
ogrinfo -so -al nz_antarctic_marks.gdb/
INFO: Open of nz_antarctic_marks.gdb/' using driver
FileGDB' successful.
Layer name: antarctic_geodetic_marks Geometry: Point Feature Count: 463 Extent: (155.894154, -81.350000) - (171.167704, -71.891729) Layer SRS WKT: GEOGCS["RSRGD2000", DATUM["Ross_Sea_Region_Geodetic_Datum_2000", SPHEROID["GRS 1980",6378137,298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0,0,0,0,0,0,0], AUTHORITY["EPSG","6764"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4764"]] FID Column = OBJECTID Geometry Column = SHAPE gml_id: String (0.0) id: Integer (0.0) geodetic_code: String (0.0) current_mark_name: String (0.0) description: String (0.0) mark_type: String (0.0) beacon_type: String (0.0) markcondition: String (0.0) order: Integer (0.0) latitude: Real (0.0) longitude: Real (0.0) ellipsoidal_height: Real (0.0)
Note: When you call ds.CreateLayer for the FileGDB datasource within python make sure you pass in the EPSG SRS code and it should work. No Morph to Esri or WKT SRS strings are required. I've successfully tested all NZ coordinate systems after the OGR library was fixed for 1.9.1.
With src_layer.GetSpatialRef() = SpatialReference: GEOGCS["RSRGD2000", DATUM["Ross_Sea_Region_Geodetic_Datum_2000", SPHEROID["GRS 1980",6378137,298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0,0,0,0,0,0,0], AUTHORITY["EPSG","6764"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4764"]]
dst_layer = dst_ds.CreateLayer(dst_layer_name,src_layer.GetSpatialRef(),dst_layer_geom,opts)
ERROR 1: Error: Failed at creating table for \antarctic_geodetic_marks (General function failure.)
This is working for me. Are you sure your authority code is set? e.g GetSpatialRef().GetAuthorityCode(None)
import ogr
import gdal
import shutil
wfs_drv = ogr.GetDriverByName('WFS')
fgdb_drv = ogr.GetDriverByName('FileGDB')
gdal.SetConfigOption('OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN', 'NO')
wfs_ds = ogr.Open('WFS:http://wfs.data.linz.govt.nz/API-KEY/v/x789/wfs')
ant_marks = wfs_ds.GetLayerByName("v:x789")
try:
shutil.rmtree("test.gdb")
except:
pass
fgdb_ds = fgdb_drv.CreateDataSource("test.gdb")
#print ant_marks.GetSpatialRef().GetAuthorityCode(None)
dst_layer = fgdb_ds.CreateLayer('ant_marks_test', srs = ant_marks.GetSpatialRef(), geom_type = ant_marks.GetGeomType())
exit(0)
'ERROR 1: Error: Failed at creating table for \ant_marks_test (General function failure.) So probably a config problem then... investigating
Latest GDAL trunk (25497) seems to fix this, probably some earlier versions too.
FileGDB won't createLayer for SR RSRGD2000 (and doesn't like reprojection in general)
Details: General Function Failure on CreateLayer() using NZGD2000 or RSRG2000
Workaround: Bypass GFF by initialising the layer with a default SR. For NZGD2000 replacing the SR title section with GCS_NZGD_2000 seems to work. However, depending on how the SR is treated internally by the driver, it may actually result in an incorrect projection. This also works for RSRGD but I'm hesitant to use this as they two projections are going to be significantly different.
TODO: Modify RSR sref to something ESRI approves of
Result: Ross Sea Region spatial refs will be incorrect. All other spatial Refs may be incorrect, depending on FGDB internal processing