I've imported a row from a Postgres DB using sqlalchemy.

One of the column types is GEOMETRY from postgis and upon import

>>>> type(row[0].geom)


class 'geoalchemy2.elements.WKBElement'

I convert to a shapely polygon (the object type I need)

boundary_geom = row[0].geom
shapely_geom = to_shape(boundary_geom)

>>>> type(shapely_geom)
<class 'shapely.geometry.multipolygon.MultiPolygon'>

I'm trying to check the crs before using the object but it does not appear to have one.

I checked in the database

select ST_SRID(geom) from public.inner_london_boundary;



for the row in question

27700 is British national grid which is what is expected.

The Well Know Binary data passed to the function should contain the SRID.

edit: i just checked and it does:

>>>> boundary_geom.srid

Why is the shapely object missing the projection metadata?

Am I just checking for it incorrectly?

do I need to set it manually no matter what?

  • Try this: boundary_geom.crs – Rodrigo Vargas Jul 24 at 21:32
  • >>>>boundary_geom.crs returns <sqlalchemy.sql.functions._FunctionGenerator object at 0x0E25E6B0> but I can check the crs of that WKBElement successfully with boundary_geom.srid. It's the shapely_geom that I'm trying to check and >>>> shapely_geom.crs returns AttributeError: 'MultiPolygon' object has no attribute 'crs' – Hugh_Kelley Jul 25 at 5:24

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.