3

I need to enlarge/expand a 2D polygon at its fixed location (lat,lon) with a constant scale factor in order to retrieve the surrounding area with the same shape as the origin polygon.

What PostGIS function can I use and is this even possible to achieve?

Principally, I'm looking for a function similar to PostGISs ST_Scale(), which only works for geometry data, which has no center.

Can you assist with the necessary transformations that come with this issue?


My Idea to solve the problem. I'm sure, that it can be formatted better:

SELECT 
st_astext(st_centroid(way)) as polygoncenter,
ST_AsText(way) as originalpolygon,
ST_AsText(
    ST_Translate(way, -ST_X(ST_AsText(ST_Centroid(way))), -ST_Y(ST_AsText(ST_Centroid(way))))
    ) as translatedtoorigin,
ST_AsText(  
    ST_SCALE(ST_Translate(way, -ST_X(ST_AsText(ST_Centroid(way))), -ST_Y(ST_AsText(ST_Centroid(way)))),2,2)
    ) as scaledatorigin,
ST_AsText(  
    ST_Translate(ST_SCALE(ST_Translate(way, -ST_X(ST_AsText(ST_Centroid(way))), -ST_Y(ST_AsText(ST_Centroid(way)))),2,2),ST_X(ST_AsText(ST_Centroid(way))), ST_Y(ST_AsText(ST_Centroid(way))))
    ) as scaledatoriginalposition
FROM de_polygon LIMIT 1000

The last parameter scaledatoriginalposition is the value I want to retrieve. Isn't there any shorter way or given functionality by Postgis to solve this problem?

1

Due to some ideas from here I was able to figure it out.

But I was actually searching for the ST_Buffer() method, which is way much easier, than this complex query. Finally, I discovered that the results were different that I expected and ST_Buffer() totally meets my needs!

Result:

SELECT 
ST_Difference(
    ST_Buffer(area, ST_MaxDistance(area, area)/2),area) as surroundingarea
FROM (SELECT way as area FROM de_polygon WHERE boundary='administrative') as t

Maybe there is someone out there, who can use this :-)

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.