4

I am quite new to postgres/postgis and are still learning basic skills. I have imported a pointlayer shapefile into my postgres database.

I need to make a buffer of varying radius around the points depending on attribute. I have been reading about the ST_buffer function in the documentation but I am having problems to interpreting it so far.

I am trying to use SELECT geometry ST_Buffer(geometry g1, float radius_of_buffer);

I have tried SELECT geometry ST(mypoints.geom, 100) FROM myschema.mypoints

I hope someone could help me to write it out properly

Best Regards

1
  • 1
    SELECT ST_Buffer(geom, 100) FROM myschema.mypoints Feb 11, 2015 at 9:02

1 Answer 1

4

If you want a conditional buffering based on some attribute, you can use a case statement, eg,

SELECT ST_Buffer(geom, CASE WHEN atr = 0 then 10 WHEN atr=1 THEN 20 ELSE 30 END) 
FROM mypoints;

Obviously, you can have as many WHENs as you like, though it could get cumbersome fast. If it is a straight multiplier, then you can just do ST_Buffer(geom, atr * 2), for example.

9
  • Thank you! <br/> I think I will use views and create one view for each attribute that need another buffer size. I have about 10 different attributes that need their own buffer size.
    – geogrow
    Feb 11, 2015 at 9:15
  • 1
    Great. If it has helped, please accept. I have edited your question to, I hope, better reflect what you are asking. Please re-edit if you disagree with me. Feb 11, 2015 at 9:18
  • Can you use conditional buffering based on attribute from a different table? <br/>
    – geogrow
    Feb 19, 2015 at 14:04
  • Yes, assuming you can join it somehow to the first table? Feb 19, 2015 at 14:06
  • Wow, that was a super fast reply! I went to edit my question bc I accidentally posted it before it was done =) I have created a view in my postgres db. I want the user to be able to put in any value in a column that the buffer radius will be generated from. In that way will the buffer be generated on the fly
    – geogrow
    Feb 19, 2015 at 14:09

Your Answer

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

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