1

I am using postgis 2.2.

I am using ST_Buffer to my polygon and it's working for positive radius (in meters) but when i am going to apply negative radius it is showing empty values.

Here is my query:

SELECT    
  ST_AsGeoJSON(
      ST_Buffer(
          ST_GeomFromText(
               'POLYGON((72.89994120597838 19.070245311788284,
                         72.89981782436371 19.069915760688904,
                         72.9002845287323 19.070001951039718,
                         72.900338172912619.070341641985888,
                         72.89991974830626 19.07023517176424,
                         72.89994120597838 19.070245311788284)
               )', 4326)
       ,-3.024)
  ) as geometry;

The Results are :

            geometry
-------------------------------------
 {"type":"Polygon","coordinates":[]}
(1 row)

How to apply negative buffer (-10 meters) to polygon (in meters)?

3

Use reasonable buffer value. The largest measure of your polygon is about 0.0007 degrees and you are shrinking it by 3.024 degrees. The result if much less than nothing.

SELECT ST_AsGeoJSON(ST_Buffer(ST_GeomFromText('POLYGON((72.89994120597838 19.070245311788284,72.89981782436371 19.069915760688904,72.9002845287323 19.070001951039718,72.9003381729126 19.070341641985888,72.89991974830626 19.07023517176424,72.89994120597838 19.070245311788284))', 4326), -0.0001)) as geometry;

gives

"{"type":"Polygon","coordinates":[[[72.9000145913706,19.0701561184588],[72.9002157176618,19.0702072960437],[72.9001967896964,19.0700874385229],[72.8999734347906,19.0700461896318],[72.9000145913706,19.0701561184588]]]}"

  • Here i want to apply negative radius in meters (5 meters). You are saying in degrees, But how can i apply negative values (i.e: -5 meters) ?? – Sanjeeva Reddy Yanala Jun 15 '16 at 6:21
  • 2
    You must convert your geometry that is in EPSG:4326 into some projected coordinate system that is using meters as units, apply the buffer, and finally convert the result back into EPSG:4326. You will need ST_Transform postgis.org/docs/ST_Transform.html for that and you can find many questions dealing with this common problem from gis.stackexchange. BTW. you write that it works in meters with positive buffer values but is does not, you are increasing your geometry in degrees. The result is valid but not what you want. – user30184 Jun 15 '16 at 6:29
  • 1
    This answer contains elements for creating meter based buffer for EPSG:4326 geometries gis.stackexchange.com/questions/194742/… – user30184 Jun 15 '16 at 7:02

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.