Hi, 

I guess you should either 
=> drop the created table prior to launch the ogr2ogr command with the -nlt 
PROMOTE_TO_MULTI switch 
=> or maually alter the existing table: ALTER TABLE schema.table ALTER COLUMN 
geom TYPE geometry(MultiPolygon, SRID) using ST_MULTI(geom) 

HTH, 
Hug 



De: "Richard Greenwood" <richard.greenw...@gmail.com> 
À: "Bo Victor Thomsen" <bo.victor.thom...@gmail.com> 
Cc: "gdal dev" <gdal-dev@lists.osgeo.org> 
Envoyé: Lundi 25 Juillet 2022 15:32:35 
Objet: Re: [gdal-dev] New behaviour of "PROMOTE_TO_MULTI" ? 

Have you tried -nlt MultiPolygon? 

On Mon, Jul 25, 2022 at 2:54 AM Bo Victor Thomsen < [ 
mailto:bo.victor.thom...@gmail.com | bo.victor.thom...@gmail.com ] > wrote: 





I have a MapInfo .tab file containing polygons, both simple and multipolygons 
(and only polygons). 

Using this command: (all ogr2ogr commands are one-liners, but examples are 
split for lucidity) 


ogr2ogr 
--config PG_USE_COPY yes 
-progress 
-lco OVERWRITE=YES 
-dim XY 
-f "PostgreSQL" PG:"host=localhost port=5432 user=*** password=*** 
dbname=geodata" 
FREDSKOV.TAB 


will (correctly) create a table in Postgres of PostGIS type "Geometry" 


If I change the command to: 

ogr2ogr 
--config PG_USE_COPY yes 
-progress 
-lco OVERWRITE=YES 
-dim XY 
-nlt PROMOTE_TO_MULTI 
-f "PostgreSQL" PG:"host=localhost port=5432 user=*** password=*** 
dbname=geodata" 
FREDSKOV.TAB 

I would expect the table to change the PostGIS type to "MultiPolygon". However 
it still is registered as "Geometry". 


Checking the table using SQL command: 

SELECT ST_geometrytype(wkb_geometry), count(*) FROM mat.fredskov group by 1 

affirms, that all geometries now is of type "ST_MultiPolygon". 

AFAIK, this is a new behaviour. Or what ? 


Postgres/Postgis version : 13.2, 3.1 


OGR2OGR version: both 3.4 andf 3.6 dev. 









-- 
Med venlig hilsen / Kind regards

Bo Victor Thomsen 
_______________________________________________ 
gdal-dev mailing list 
[ mailto:gdal-dev@lists.osgeo.org | gdal-dev@lists.osgeo.org ] 
[ https://lists.osgeo.org/mailman/listinfo/gdal-dev | 
https://lists.osgeo.org/mailman/listinfo/gdal-dev ] 





-- 
Richard W. Greenwood 
[ http://www.greenwoodmap.com/ | www.greenwoodmap.com ] 


[Fichier texte:ATT00001] 
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to