Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ogr2ogr not copying correct types from wfs to postgres #3428

Closed
adamal opened this issue Feb 2, 2021 · 1 comment
Closed

ogr2ogr not copying correct types from wfs to postgres #3428

adamal opened this issue Feb 2, 2021 · 1 comment

Comments

@adamal
Copy link

adamal commented Feb 2, 2021

Expected behavior and actual behavior.

I am copying features from a WFS source to a Postgres (with Postgis) database.
The data is copied, but data types are not always transferred correctly. It seems they are inferred from data and defaults to varchar if data is NULL.

This seems related to #1375.
With hints from there, I tried adding the --debug on flag. From the output, I can see that a request to the WFS-server is made with query parameter request=DescribeFeatureType (aside: this request is not logged if requesting data as json).
Trying the logged url in Postman, I can also see that the response says my column of interest is of type datetime.

Yet, as long as the field's value (this particular table has only 1 row) it is imported to Postgres as varchar.
If the value at the source is set to a value (timestamp is the source table's type), the import runs and the column is typed timestamptz (which is still not identical, but much better).

Steps to reproduce the problem.

Unfortunately, the WFS service itself is not public, so I can't share it here for further inspection.
The ogr2ogr call is similar to this:

ogr2ogr \
-overwrite \
-f "PostgreSQL" PG:"dbname='my_db' host='localhost' port='5432' user='postgres' password='postgres'" \
"https://wfs.company.com/puma/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=puma:our_things&srsName=EPSG:4326" \
-nln "my_schema.our_things" \
-lco FID="gid" \
-lco GEOMETRY_NAME='geom' \
-a_srs "EPSG:4326" \
--config GDAL_HTTP_HEADER_FILE "header.tmp" \
--debug on

Operating system

macOS 10.14.6

GDAL version and provenance

3.2.0_1 via Homebrew

@jratike80
Copy link
Collaborator

jratike80 commented Feb 2, 2021

Missing test data makes it really much harder to try to help you.

Try these commands:

ogrinfo WFS:"https://wfs.company.com/puma/ows?" --debug on

You should get a layer list. Run then (I guess that puma:our_things will be one layer on that list).

ogrinfo WFS:"https://wfs.company.com/puma/ows?" puma:our_things -so --debug on

Have a look at the attribute types. What type is advertized for the timestamp field?

@rouault rouault closed this as completed Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants