2

I have to store some polygons in a MySQL database. The polygons are in Plate Carrée (ESPG 32662) projection, but I also tried to first converting them to the usual latitude-longitude projection (ESPG 4326) and it did not work either.

First I upload the shapely polygon to the database:

polygon_text = my_shapely_polygon.to_wkt()
query = f"""
                INSERT INTO
                    lands (polygon_id, geometry)
                VALUES
                    ({id}, ST_GeomFromText({polygon_text}));
        """

The type of the column geometry in the database is set to POLYGON. However, when I retrieve the geometry and do

shapely.wkb.loads(retrieved_polygon)

I get a point, not a polygon. The same thing happens if I try to upload the polygon as WKB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.