I am importing Polygon shapes into a PostGIS database, using Python (GeoPandas, SQLAlchemy, GeoAlchemy2). I followed the instructions mentioned here.
I have a database with a table named maps_region
with a column/field called geom
.
I am able to get the Polygon field (named geom
) to import into the PostGIS database table in text format (WKT, WKB, and WKB Hex), but, I am unable to successfully convert this text column into a proper Polygon format in the database.
I tried importing with the geom
field in several different formats-- in Well-Known Text (WKT) format, WKB format, and WKB Hex format-- but could not convert to Polygon from any of the three formats.
For instance, I imported the shapes into the geom
field as WKT format, and then converted to WKB Hex format, using the following command, which worked fine:
database=> UPDATE maps_region SET geom = ST_GeomFromText(geom, 4326);
UPDATE 28
However, when I then try to convert the geom
field from a text
format into a Polygon
type, I get the following errors:
database=> ALTER TABLE maps_region ALTER COLUMN geom TYPE Geometry(POLYGON, 4326);
ERROR: Geometry type (MultiPolygon) does not match column type (Polygon)
database=> ALTER TABLE maps_region ALTER COLUMN geom TYPE Geometry(MULTIPOLYGON, 4326);
ERROR: Geometry type (Polygon) does not match column type (MultiPolygon)
I tried both ways: converting to Polygon, and converting to MultiPolygon-- and neither worked. Instead, the error messages were just reversed!
Any help would be greatly, greatly appreciated.
Thanks in advance!