[gdal-dev] curved polygon -> polygon

Even Rouault even.rouault at spatialys.com
Wed Nov 26 03:43:07 PST 2014


Le mercredi 26 novembre 2014 12:17:38, Martin Landa a écrit :
> Hi,
> 
> I wonder why curved polygons are not approximated to polygons somehow
> automatically. Eg. conversion such data fails
> 
> $ ogr2ogr -f PostgreSQL PG:dbname=ruian_test
> /vsicurl/http://vdp.cuzk.cz/vymenny_format/soucasna/20141031_OB_564567_UKSH
> .xml.gz Parcely -overwrite
> Warning 1: Geometry to be inserted is of type Curve Polygon, whereas
> the layer geometry type is Polygon.
> Insertion is likely to fail
> ERROR 1: COPY statement failed.
> ERROR:  Geometry type (CurvePolygon) does not match column type (Polygon)
> CONTEXT:  COPY parcely, line 18, column originalnihranice:
> "010A00002032BF0D000100000001090000000300000001020000000B0000008FC2F528750A
> 27C11F85EB51933C2EC114AE47..."
> 
> because some features are curved polygons even geometry column is
> `polygon`:

Martin,

The PostGIS driver doesn't do automatic conversion of geometry types as it can 
support all (you would get similar errors if inserting polygons into a 
multipolygon layer, or the reverse). This is kind of historic behaviour.
You can fix the error by specifying either -nlt CONVERT_TO_LINEAR (or -nlt 
POLYGON), or -nlt CURVEPOLYGON

Actually digging more, I was convinced that in my work related to curve 
geometries, I had make sure that the GML reader does its best to convert each 
geometry to the layer declared geometry type. This indeed worked for single 
geometry column layers, but not for multiple geometry such as yours. I've just 
fixed that.
So, with your current  data/ruian_vf_ob_v1.gfs, the curve polygons will be 
converted/approximated to polygons. You can also change 
data/ruian_vf_ob_v1.gfs to declare OriginalniHranice as curvepolygon. And 
polygons will be converted to curvepolygons (lossless conversion of course).
In both cases, PostGIS should be happy.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list