4

I have achieved to close lines in order to build a polygon with:

st_addpoint(
    st_makeline(geom ORDER BY .cd_noseq), 
    st_pointn(
        st_makeline(geom ORDER BY cd_noseq), 
    1)
)

but then, when I try to make a polygon with st_makepolygon like this:

st_makepolygon(
    st_addpoint(
        st_makeline(geom ORDER BY cd_noseq), 
        st_pointn(
            st_makeline(geom ORDER BY cd_noseq), 
        1)
    )
) as geom

I get the following error:

ERROR:  lwpoly_from_lwlines: shell must have at least 4 points
********** Error **********

ERROR: lwpoly_from_lwlines: shell must have at least 4 points
SQL state: XX000

Technology:

PostgreSQL 9.2.7 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4), 64-bit" "POSTGIS="2.1.1 r12113" GEOS="3.4.2-CAPI-1.8.2 r3921" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.9.2, released 2012/10/08" LIBXML="2.7.6" LIBJSON="UNKNOWN" (core procs from "2.1.0 r11822" need upgrade) TOPOLOGY (topology procs from "2.1.0 r11822" need upg (…)

5

Your query looks good. According to the source the error message means exactly what it says. One of your linestrings doesn't have at least 4 points.

Check your results with ST_NumPoints!

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.