2

Could I load spatial data to Oracle when table structure was created before this step? Specifically I have problem with default name of attribute OGR_FID . If my primary key has different name, I can't load data.

ogr2ogr -append -f "OCI" OCI:abcd/abcd@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=a000000)(PORT=1521))(CONNECT_DATA=(SID=hop))) PG:"host=w111111 user=post dbname=gis password=gres" -sql "select row_number() OVER (ORDER BY null) fid,typppd,geom from zab.table" -lco MULTI_LOAD=yes -lco GEOMETRY_NAME=sdo_geom -nln HRANICE

I found Layer Creation Options -lco FID=id in PostGIS driver implementation, but OCI ignore this in my opinion.

2

According to the documentation of the OCI driver (http://www.gdal.org/ogr/drv_oci.html) ogr always creates a column called OGR_FID to be used as row identifier. When appending, the new rows get new values for OGR_FID.

That is the behaviour I observe too: - the first load creates the table, including an OGR_FID column. - the subsequent append loads and keeps on populating OGR_FID.

According to the documentation: "If the table has an integer column called OGR_FID it will be used as the feature id by OGR". I take that to mean that it is fine for an existing table to have no OGR_FID column, but that does not work: the -append load fails with a segmentation fault.

The doc also says: "To force use of a particular field name the OCI_FID configuration variable (ie. environment variable) can be set to the target field name." That works fine: if you set

export OCI_FID=ID

before calling ogr2ogr, then the unique identifier column will be called ID. That works for the -append runs too.

But in both cases, the "feature identifier" column - whatever its name: the default OGR_FID or your own name - is always created and managed by ogr2ogr. From what I see it is not possible for you to fill it with your own values.

If all you want is to use another name, then use the export method above. If you want to fully manage it yourself, for example populate if with your own values, then I don't see this as being possible. Your best approach is just to create the output table with your own unique identifier column (FID) that you can them populate at will, while letting ogr define and mange its own identifier (OGR_FID).

Note that ogr does not create OGR_FID as a primary key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.