Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Geometry type Poly not match MultiPoly #14870

Closed
qgib opened this issue Mar 2, 2012 · 32 comments
Closed

ERROR: Geometry type Poly not match MultiPoly #14870

qgib opened this issue Mar 2, 2012 · 32 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers

Comments

@qgib
Copy link
Contributor

qgib commented Mar 2, 2012

Author Name: Salvatore Larosa (@slarosa)
Original Redmine Issue: 5109
Affected QGIS version: master
Redmine category:data_provider/postgis
Assignee: Salvatore Larosa


Hi,
when I try to add a new geometries and then stop editing (save) I get this error:

Errore PostGIS nell'aggiunta delle geometrie: ERROR:  Geometry type (Polygon) does not match column type (MultiPolygon)

My features PostGIS is MULTIPOLYGON



Related issue(s): #16497 (duplicates)
Redmine related issue(s): 7555


@qgib
Copy link
Contributor Author

qgib commented Mar 22, 2012

Author Name: Andreas Neumann (@andreasneumann)


Hi,

what are the constraints in the table in Postgis. The error message sounds like a Postgis problem - not like a QGIS problem.

There are two potential issues in Postgis:

  • constraints: you can allow either Multipolygon or polygon or both
  • an invalid entry in public.geometry_columns

Theoretically it could also be a QGIS problem - but I would first make sure that everything on the Postgis side is ok?

@qgib
Copy link
Contributor Author

qgib commented Mar 23, 2012

Author Name: Salvatore Larosa (@slarosa)


Hi, my table is:

CREATE TABLE test.prov
(
  gid serial NOT NULL,
  provincia character varying(30),
  cod_pro character varying(3),
  sigla character varying(2),
  cod_reg character varying(2),
  sede character varying(50),
  anno_volo numeric(10,0),
  liv_utente numeric(10,0),
  geom geometry(MultiPolygon,3004),
  CONSTRAINT prov_pkey PRIMARY KEY (gid ),
)

I did try to add some constraints:

CONSTRAINT enforce_dims CHECK (st_ndims(geom) = 2),
CONSTRAINT enforce_geometry_type CHECK (geometrytype(geom) = 'MULTIPOLYGON'::text OR geom IS NULL)

but I got the same error!

more info:

workshop=# SELECT * FROM public.geometry_columns WHERE f_table_name = 'prov';
 f_table_catalog | f_table_schema | f_table_name | f_geometry_column | coord_dimension | srid |     type     
-----------------+----------------+--------------+-------------------+-----------------+------+--------------
 workshop        | test           | prov         | geom              |               2 | 3004 | MULTIPOLYGON
(1 row)


workshop=# SELECT postgis_full_version();
                                                                       postgis_full_version                                                    
                   
-----------------------------------------------------------------------------------------------------------------------------------------------
-------------------
 POSTGIS="2.0.0beta5SVN r9530" GEOS="3.3.2-CAPI-1.7.2" PROJ="Rel. 4.7.1, 23 September 2009" GDAL="GDAL 1.9.0, released 2011/12/29" LIBXML="2.7.
8" TOPOLOGY RASTER
(1 row)




Thanks!

@qgib
Copy link
Contributor Author

qgib commented Mar 24, 2012

Author Name: Jürgen Fischer (@jef-n)


Salvatore Larosa wrote:

I did try to add some constraints:
CONSTRAINT enforce_dims CHECK (st_ndims(geom) = 2),
CONSTRAINT enforce_geometry_type CHECK (geometrytype(geom) = 'MULTIPOLYGON'::text OR geom IS NULL)
but I got the same error!

The constraint is the problem (or QGIS' ignorance about it, if you like). Changing it to

CONSTRAINT enforce_geometry_type CHECK (geometrytype(geom) = 'MULTIPOLYGON'::text OR geometrytype(geom) = 'POLYGON'::text OR geom IS NULL)

could help.

@qgib
Copy link
Contributor Author

qgib commented Mar 24, 2012

Author Name: Salvatore Larosa (@slarosa)


Jürgen Fischer wrote:

The constraint is the problem (or QGIS' ignorance about it, if you like). Changing it to

[...]

could help.

Thanks for the advice, but does not solve the problem!
If that works for you means that the problem is only mine! so?

@qgib
Copy link
Contributor Author

qgib commented Mar 24, 2012

Author Name: Salvatore Larosa (@slarosa)


I noticed that it happens only if the geometry is identified as a 'MULTI[LINESTRING,POINT,POLYGON]'

@qgib
Copy link
Contributor Author

qgib commented Mar 24, 2012

Author Name: Jürgen Fischer (@jef-n)


Salvatore Larosa wrote:

I noticed that it happens only if the geometry is identified as a 'MULTI[LINESTRING,POINT,POLYGON]'

That's what I meant. You're trying to save a @polygon@ into a table that you restricted to @multipolygon@ s.

But I admit that the postgres provider could internally convert the @polygon@ to a @multipolygon@ if necessary, but it currently just determines if the layer is a point, line or polygon layer as higher levels don't differentiate between single and multi geometries.

@qgib
Copy link
Contributor Author

qgib commented Mar 24, 2012

Author Name: Salvatore Larosa (@slarosa)


Something terrible has happened! :-)

I tried to edit and save with QGIS 1.7.3 (on the PC of a friend, but after that I hate :-)) on windows, and it works perfect!
I used the same table as I have created a connection that pointed to my linux machine!

In Linux with the master version, why not?

@qgib
Copy link
Contributor Author

qgib commented Mar 24, 2012

Author Name: Salvatore Larosa (@slarosa)


I also tried the version 1.7.4 is working correctly on Windows!
The problem seems to be present only in the master version on Linux!

@qgib
Copy link
Contributor Author

qgib commented Mar 25, 2012

Author Name: Jürgen Fischer (@jef-n)


4945611 should fix this.

@qgib
Copy link
Contributor Author

qgib commented Mar 25, 2012

Author Name: Salvatore Larosa (@slarosa)


Jürgen Fischer wrote:

4945611 should fix this.

Yes, solved!
Thanks!
I can't change the status ticket to closed, because I haven't rigths to do it, evidently!

One more thing, Might it solve the problem very like with the SPIT plugin?
Worth to file a new ticket?

@qgib
Copy link
Contributor Author

qgib commented Mar 25, 2012

Author Name: Jürgen Fischer (@jef-n)


Salvatore Larosa wrote:

One more thing, Might it solve the problem very like with the SPIT plugin?
Worth to file a new ticket?

Give it a spin. I'd expect that one is solved too.


  • resolution was changed from to fixed
  • status_id was changed from Open to Closed

@qgib
Copy link
Contributor Author

qgib commented Aug 9, 2012

Author Name: Maximilian L. (Maximilian L.)


Salvatore Larosa wrote:

I also tried the version 1.7.4 is working correctly on Windows!
The problem seems to be present only in the master version on Linux!

I tested 1.7.4 and 1.8 on Windows 7 but got the same error-message in SPIT. :( How can I fix this easily on windows?

@qgib
Copy link
Contributor Author

qgib commented Aug 9, 2012

Author Name: Salvatore Larosa (@slarosa)


Maximilian L. wrote:

I tested 1.7.4 and 1.8 on Windows 7 but got the same error-message in SPIT. :( How can I fix this easily on windows?

Actually there is not any solution for that, the better way to import SHP into PostGIS is with DB Manager plugin!

Also have a look at this #15029, the SPIT plugin will be removed!

@qgib
Copy link
Contributor Author

qgib commented Aug 12, 2012

Author Name: Maximilian L. (Maximilian L.)


Salvatore Larosa wrote:

Actually there is not any solution for that, the better way to import SHP into PostGIS is with DB Manager plugin!

Also have a look at this #15029, the SPIT plugin will be removed!

Thank you for this information. But trying to import SHP into PostGIS with DB Manager brings me the same error (see picture).


  • 4769 was configured as postgis.jpg

  • postgis.jpg (Maximilian L.) - Error message when adding a multipolygon shapefile wtih DB Manager.

@qgib
Copy link
Contributor Author

qgib commented Aug 12, 2012

Author Name: Salvatore Larosa (@slarosa)


Maximilian L. wrote:

Thank you for this information. But trying to import SHP into PostGIS with DB Manager brings me the same error (see picture).

I am aware of that!
I already filed this ticket #15140!
It is occurs because your polygon dataset has some multipolygon geometries.
Right now, one possible solution is to convert your dataset from multiparts to singlepart by Vector > Geometry Tools > Multipart to singleparts tool (fTool) and then import it by DbManager.

@qgib
Copy link
Contributor Author

qgib commented Aug 12, 2012

Author Name: Maximilian L. (Maximilian L.)


I already filed this ticket #15140!

Thank you!

It is occurs because your polygon dataset has some multipolygon geometries.
Right now, one possible solution is to convert your dataset from multiparts to singlepart by Vector > Geometry Tools > Multipart to singleparts tool (fTool) and then import it by DbManager.

I know but this is no solution for me...seems that I have to use the PostGIS Shapefile Loader.

@qgib
Copy link
Contributor Author

qgib commented Aug 13, 2012

Author Name: Giovanni Manghi (@gioman)


Maximilian L. wrote:

I know but this is no solution for me...seems that I have to use the PostGIS Shapefile Loader.

so also the "PostGIS Manager" plugin works for you?

@qgib
Copy link
Contributor Author

qgib commented Aug 13, 2012

Author Name: Salvatore Larosa (@slarosa)


Giovanni Manghi wrote:

Maximilian L. wrote:

I know but this is no solution for me...seems that I have to use the PostGIS Shapefile Loader.

so also the "PostGIS Manager" plugin works for you?

I think Maximilian was referring to shp2pgsql-gui importer!
Unfortunately, no QGIS plugin at the moment works!

@qgib
Copy link
Contributor Author

qgib commented Aug 13, 2012

Author Name: Giovanni Manghi (@gioman)


I think Maximilian was referring to shp2pgsql-gui importer!
Unfortunately, no QGIS plugin at the moment works!

postgis manager uses shp2pgsql so it should work

@qgib
Copy link
Contributor Author

qgib commented Aug 13, 2012

Author Name: Salvatore Larosa (@slarosa)


Giovanni Manghi wrote:

I think Maximilian was referring to shp2pgsql-gui importer!
Unfortunately, no QGIS plugin at the moment works!

postgis manager uses shp2pgsql so it should work

You're right, works fine!

Also, I guess there is a redundance between PostGIS Manager, Spatialite Manager and
RT_SQL Layer plugins. I do not know if they still maintained but should be removed IMO.
DBManager already does all of that!

@qgib
Copy link
Contributor Author

qgib commented Aug 13, 2012

Author Name: Giovanni Manghi (@gioman)


Also, I guess there is a redundance between PostGIS Manager, Spatialite Manager and
RT_SQL Layer plugins. I do not know if they still maintained but should be removed IMO.
DBManager already does all of that!

PostGIS manager is abandoned and it will be removed when all its feature will be ported in DB manager. Same for SL manager. I'm not sure but also the RT_SQL plugins will be integrated into DB manager.

Anyway, DB manager does not uses shp2pgsql (to avoid have the user install postgis) but it sometimes fails, like in this case. So please file a ticket against DB manager, give it to Giuseppe and if possible attach a sample of the data.

@qgib
Copy link
Contributor Author

qgib commented Aug 13, 2012

Author Name: Maximilian L. (Maximilian L.)


Salvatore Larosa wrote:

Giovanni Manghi wrote:

postgis manager uses shp2pgsql so it should work

You're right, works fine!

For me it does not: "somethings wrong: The command "shp2pgsql" is wrong written or couldn't be found". In addition I had to edit 2 .py-files of the extension in combination with PostGIS 2.0 to not have an error log at startup.

@qgib
Copy link
Contributor Author

qgib commented Aug 13, 2012

Author Name: Giovanni Manghi (@gioman)


Maximilian L. wrote:

Salvatore Larosa wrote:

Giovanni Manghi wrote:

postgis manager uses shp2pgsql so it should work

You're right, works fine!

For me it does not: "somethings wrong: The command "shp2pgsql" is wrong written or couldn't be found". In addition I had to edit 2 .py-files of the extension in combination with PostGIS 2.0 to not have an error log at startup.

maybe you don't have shp2pgsql in your path. Under Windows must be added manually.

@qgib
Copy link
Contributor Author

qgib commented Aug 13, 2012

Author Name: Maximilian L. (Maximilian L.)


Giovanni Manghi wrote:

Maximilian L. wrote:

Salvatore Larosa wrote:

Giovanni Manghi wrote:

postgis manager uses shp2pgsql so it should work

You're right, works fine!

For me it does not: "somethings wrong: The command "shp2pgsql" is wrong written or couldn't be found". In addition I had to edit 2 .py-files of the extension in combination with PostGIS 2.0 to not have an error log at startup.

maybe you don't have shp2pgsql in your path. Under Windows must be added manually.

Where I have to add it? Okay, than it is perhaps my mistake.

@qgib
Copy link
Contributor Author

qgib commented Aug 16, 2012

Author Name: Giovanni Manghi (@gioman)


Where I have to add it? Okay, than it is perhaps my mistake.

you have to add the path (that points to the folder were shp2pgsql resides) into the "path" Windows environment variable. You find this option in the advanced system settings in your Windows control panel.

@qgib
Copy link
Contributor Author

qgib commented Aug 16, 2012

Author Name: Maximilian L. (Maximilian L.)


Giovanni Manghi wrote:

you have to add the path (that points to the folder were shp2pgsql resides) into the "path" Windows environment variable. You find this option in the advanced system settings in your Windows control panel.

Well, this is what I did, but it didn't help (after restart).

@qgib
Copy link
Contributor Author

qgib commented Aug 16, 2012

Author Name: Giovanni Manghi (@gioman)


Well, this is what I did, but it didn't help (after restart).

odd, because it certainly works.

Try open the Windows terminal and enter the command

shp2psql

what happens?

@qgib
Copy link
Contributor Author

qgib commented Aug 16, 2012

Author Name: Maximilian L. (Maximilian L.)


Giovanni Manghi wrote:

odd, because it certainly works.
Try open the Windows terminal and enter the command
shp2psql
what happens?

Same error message: "Command not found or wrong written". Variable is shp2pgsql and the value is the path where the shp2pgsql.exe is.

@qgib
Copy link
Contributor Author

qgib commented Aug 16, 2012

Author Name: Giovanni Manghi (@gioman)


Same error message: "Command not found or wrong written". Variable is shp2pgsql and the value is the path where the shp2pgsql.exe is.

I'm sorry, it means that you have done something wrong. Until the command is not available trough the command line interface it cannot work in QGIS.

But anyway, this is why DB Manager does not use shp2pgsql. If you have any error using DB manager then please file a ticket, give it to giuseppe sucameli, and add sample data (along with the error message).

@qgib
Copy link
Contributor Author

qgib commented Aug 16, 2012

Author Name: Maximilian L. (Maximilian L.)


I'm sorry, it means that you have done something wrong. Until the command is not available trough the command line interface it cannot work in QGIS.

This is what I've done --> shp2pgsql.jpg


  • 4786 was configured as shp2pgsql.jpg

@qgib
Copy link
Contributor Author

qgib commented Jul 9, 2013

Author Name: Carlos Alberto Machicado Cabezas (Carlos Alberto Machicado Cabezas)


Found a solution focused on the shapelfile data, the problem lies in the geometry in this case multipolygon Multipart a way to simplify the geometry of Multipart To Singlepart(multipolygon to polygon) found in the Data Management's toolbox of ArcGis. Regards
Carlos Alberto Machicado


  • assigned_to_id was configured as Salvatore Larosa
  • 5965 was configured as multipart-singlepart.jpg
  • status_id was changed from Closed to Reopened

@qgib
Copy link
Contributor Author

qgib commented Jul 9, 2013

Author Name: Giovanni Manghi (@gioman)


Carlos Alberto Machicado Cabezas wrote:

Found a solution focused on the shapelfile data, the problem lies in the geometry in this case multipolygon Multipart a way to simplify the geometry of Multipart To Singlepart(multipolygon to polygon) found in the Data Management's toolbox of ArcGis. Regards
Carlos Alberto Machicado

why reopening this ticket? the multipart to singlepart tool there is also in qgis, what is your point? cheers!


  • status_id was changed from Reopened to Closed

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers labels May 24, 2019
@qgib qgib closed this as completed May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers
Projects
None yet
Development

No branches or pull requests

1 participant