<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Thanks to Hugues and Richard for responding to my questions.</p>
However, I'm using the ogr2ogr inside a DOS .cmd file like this: <br>
<p><font face="monospace">for /R D:\tmp %%f in (*.tab) do ogr2ogr
--config PG_USE_COPY yes -progress -lco OVERWRITE=YES -lco
SCHEMA=mat -dim XY -a_srs EPSG:25832 -f "PostgreSQL"
PG:"host=localhost port=5432 user=*** password=***
dbname=geodata" "%%f"<br>
</font></p>
<p>I.e. iterating through a directory plus sub-directories and
converting every found tab file into a table into schema "mat"
using ogr2ogr<br>
</p>
<p>The tab files contains either points, linestrings or polygons.
Polygons and linestrings can be a mix of simple and multi-objects.
Each tab-file contains only one main type.<br>
</p>
<p>So I can't use <font face="monospace">"-nlt multipolygons"</font>.
And the point of this project was to get rid of a fairly complex
postgres based function that checks an uploaded table and change
its geometry type using "alter table ... using st_multi(geom)"
type of commands.</p>
<p>That was why I tried to use <font face="monospace">"-nlt
promote_to_multi"</font>. According to this mail: <br>
</p>
<p><a class="moz-txt-link-freetext" href="https://lists.osgeo.org/pipermail/gdal-dev/2012-September/034128.html">https://lists.osgeo.org/pipermail/gdal-dev/2012-September/034128.html</a></p>
<p>Even Rouault describes the exact behaviour I'm looking for:
Simple linestrings / polygons will be changed to multi types and
points will be left alone. And the geometry type will be set to a
"multi*" as needed.<br>
</p>
<p>What actually happens is that linestrings, polygons <i>and</i>
points all are changed to multi type, but the geometry type
remains "Geometry".<br>
</p>
<p><br>
</p>
<pre class="moz-signature" cols="72">Med venlig hilsen / Kind regards
Bo Victor Thomsen</pre>
<div class="moz-cite-prefix">Den 25-07-2022 kl. 15:52 skrev Hugues
François:<br>
</div>
<blockquote type="cite"
cite="mid:742711968.14136783.1658757125530.JavaMail.zimbra@inrae.fr">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div style="font-family: garamond,new york,times,serif; font-size:
12pt; color: #000000">
<div>Hi,</div>
<div><br data-mce-bogus="1">
</div>
<div>I guess you should either</div>
<div>=> drop the created table prior to launch the ogr2ogr
command with the -nlt PROMOTE_TO_MULTI switch</div>
<div>=> or maually alter the existing table: ALTER TABLE
schema.table ALTER COLUMN geom TYPE geometry(MultiPolygon,
SRID) using ST_MULTI(geom)</div>
<div><br data-mce-bogus="1">
</div>
<div>HTH,</div>
<div>Hug</div>
<div><br>
</div>
<div><br data-mce-bogus="1">
</div>
<hr id="zwchr" data-marker="__DIVIDER__">
<div data-marker="__HEADERS__"><b>De: </b>"Richard Greenwood"
<a class="moz-txt-link-rfc2396E" href="mailto:richard.greenwood@gmail.com"><richard.greenwood@gmail.com></a><br>
<b>À: </b>"Bo Victor Thomsen"
<a class="moz-txt-link-rfc2396E" href="mailto:bo.victor.thomsen@gmail.com"><bo.victor.thomsen@gmail.com></a><br>
<b>Cc: </b>"gdal dev" <a class="moz-txt-link-rfc2396E" href="mailto:gdal-dev@lists.osgeo.org"><gdal-dev@lists.osgeo.org></a><br>
<b>Envoyé: </b>Lundi 25 Juillet 2022 15:32:35<br>
<b>Objet: </b>Re: [gdal-dev] New behaviour of
"PROMOTE_TO_MULTI" ?<br>
</div>
<div><br>
</div>
<div data-marker="__QUOTED_TEXT__">
<div dir="ltr">Have you tried -nlt MultiPolygon?</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, Jul 25, 2022 at
2:54 AM Bo Victor Thomsen <<a
href="mailto:bo.victor.thomsen@gmail.com"
target="_blank" moz-do-not-send="true"
class="moz-txt-link-freetext">bo.victor.thomsen@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div>
<p>I have a MapInfo .tab file containing polygons, both
simple and multipolygons (and only polygons).</p>
<p>Using this command: (all ogr2ogr commands are
one-liners, but examples are split for lucidity)<br>
</p>
<p><font face="monospace">ogr2ogr <br>
--config PG_USE_COPY yes <br>
-progress <br>
-lco OVERWRITE=YES <br>
-dim XY <br>
-f "PostgreSQL" PG:"host=localhost port=5432
user=*** password=*** dbname=geodata" <br>
FREDSKOV.TAB<br>
</font></p>
<p>will (correctly) create a table in Postgres of
PostGIS type "Geometry" <br>
</p>
<p>If I change the command to:</p>
<p><font face="monospace">ogr2ogr <br>
--config PG_USE_COPY yes <br>
-progress <br>
-lco OVERWRITE=YES <br>
-dim XY <br>
<b> -nlt PROMOTE_TO_MULTI</b><br>
-f "PostgreSQL" PG:"host=localhost port=5432
user=*** password=*** dbname=geodata" <br>
FREDSKOV.TAB</font></p>
<p>I would expect the table to change the PostGIS type
to "MultiPolygon". However it still is registered as
"Geometry".<br>
</p>
<p>Checking the table using SQL command:</p>
<p><font face="monospace">SELECT
ST_geometrytype(wkb_geometry), count(*) FROM
mat.fredskov group by 1</font></p>
<p>affirms, that all geometries now is of type
"ST_MultiPolygon".</p>
<p>AFAIK, this is a new behaviour. Or what ? <br>
</p>
<p>Postgres/Postgis version : 13.2, 3.1 <br>
</p>
<p>OGR2OGR version: both 3.4 andf 3.6 dev.<br>
</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
<pre>--
Med venlig hilsen / Kind regards
Bo Victor Thomsen</pre>
</div>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank"
moz-do-not-send="true" class="moz-txt-link-freetext">gdal-dev@lists.osgeo.org</a><br>
<a
href="https://lists.osgeo.org/mailman/listinfo/gdal-dev"
rel="noreferrer" target="_blank" moz-do-not-send="true"
class="moz-txt-link-freetext">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote>
</div>
<br clear="all">
<br>
-- <br>
<div dir="ltr" class="gmail_signature">
<div dir="ltr">Richard W. Greenwood<br>
<a href="http://www.greenwoodmap.com" target="_blank"
moz-do-not-send="true">www.greenwoodmap.com</a></div>
</div>
<br>
<br>
[Fichier texte:ATT00001]<br>
</div>
</div>
</blockquote>
</body>
</html>