Skip to content

Can't create a Postgis table from a geojson file #316

Open
@ericemc3

Description

@ericemc3

What happens?

I want to create a spatial table into my Postgis Database from a geojson file, using duckdb-postgres.

To Reproduce

CREATE OR REPLACE TABLE postgres_db.provincie_2025 AS
FROM st_read('https://cartomap.github.io/nl/wgs84/provincie_2025.geojson');

This fails:

SQL Error: Invalid Error: Failed to copy data: ERREUR:  Invalid endian flag value encountered.
CONTEXT:  COPY provincie_2025, ligne 1, colonne geom

However, this will work, but is much more complex:

CREATE OR REPLACE TABLE postgres_db.provincie_2025 AS
FROM st_read('https://cartomap.github.io/nl/wgs84/provincie_2025.geojson')
SELECT * replace(st_astext(geom) AS geom);

CALL postgres_execute('postgres_db', 
"alter table provincie_2025 add column geom_4326 GEOMETRY('MULTIPOLYGON', '4326');
update provincie_2025 set geom_4326 = ST_GeomFromText(geom);
alter table provincie_2025 drop column geom");

OS:

Win11

PostgreSQL Version:

16.0

DuckDB Version:

1.2.2

DuckDB Client:

Java

Full Name:

eric mauviere

Affiliation:

icem7

Have you tried this on the latest main branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions