duckdb / duckdb/duckdb-postgres

Can't create a Postgis table from a geojson file

Open
#316 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
372
Forks
105
Avg merge
10h 19m
Merged PRs (30d)
18

Description

### 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?

- [x] 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?

- [x] I agree

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.