5

I am trying to make a buffer(0) as a fix-geometry process in PostGIS 2.2.2. It like this:

SELECT ST_Buffer(ST_GeomFromText('POINT(100 90)'),0,4);

I am using sources from this man-page. It creates an output that goes like this:

  ----------------------
  010300000000000000000
  (1 row)

But I am not sure if I am actually just simulating the creation of a buffer in PostGIS or I am actually making a buffer on database#scheme.table

What I would like to is to make an ST_Buffer of all the geometries (polygon) in the table. Seems like getting something wrong. The syntax is foreign to me though.

I have experienced that it isn't like: ST_Buffer(scheme.table, 0) but how am I to understand these examples?

3
  • Further I've tried to query it this way: SELECT ST_Buffer('scheme.table', 0); Which outputs: ERROR: parse error - invalid geometry HINT: "im" <-- parse error at position 2 within geometry CONTEXT: SQL function "st_buffer" statement 1
    – MichaelR
    Jul 4, 2016 at 15:49
  • I don't understand what exactly you want to achieve. Are you trying to select a "buffered" version of your geometries or are you trying to change the geometries to the "buffered" version?
    – vagvaf
    Jul 4, 2016 at 16:07
  • None of the above. I am trying to make a buffer on the geometries.
    – MichaelR
    Jul 4, 2016 at 16:31

1 Answer 1

6

What you want is:

SELECT ST_Buffer(geometry_column, 0) FROM scheme.table

Where geometry_column is the column within your table (scheme.table) that contains your geometry.

You current result of:

  ----------------------
  010300000000000000000
  (1 row)

Looks correct, that is the well known binary version of the geometry, or how PostgreSQL sees it. For human readable try:

SELECT ST_AsText(ST_Buffer(ST_GeomFromText('POINT(100 90)'),0,4));

Result:

POLYGON EMPTY

Obviously a 0 unit buffer of a point will result in an empty polygon.

While that is one way to fix geometries. A better solution would be ST_MakeValid.

14
  • 1
    That error suggests that your geometry_column is not of type geometry. Can you post your create table statement, and possibly a couple of sample records?
    – mlinth
    Jul 5, 2016 at 8:22
  • 2
    When I started with PostGIS I used the Boundless tutorial: workshops.boundlessgeo.com/postgis-intro I would heavily recommend running through the full intro to get a basic grasp of how PostGIS works. Run through at least exercises 1-21. 21 will answer most of your questions about validity as well. Jul 5, 2016 at 12:07
  • 2
    You have PGAdmin, right? Navigate through the tree in the "object browser" (database server, database, schema...) and click on the table. In the "SQL Pane" in the bottom half of the right-hand side of the screen you should see see some SQL beginning "CREATE TABLE". Copy that and add it to your question. That way we know the names and types of all your columns and can help you better...
    – mlinth
    Jul 5, 2016 at 18:38
  • 1
    So run: SELECT ST_Buffer(geom, 0) FROM import.imp_tabl_spmgnt100all_netto Jul 6, 2016 at 16:22
  • 1
    Try: SELECT ST_Buffer(geom, 10) FROM import.imp_tabl_spmgnt100all_netto Jul 6, 2016 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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