3

I have a layer.

I want to transform the type of geometry from point to polygon while creating a buffer around points proportional to the population of cities.

I'm testing :

ALTER TABLE city 
ALTER COLUMN points TYPE POLYGON USING ST_buffer ('points', pop * 100)

but that does not work...

Can anyone put me on the right track?

  • 1
    Surely you get a different error message than "that does not work"? Which data type does your layer have? Why do you want to alter its geometry instead of creating the buffer as new polygon layer? – Erik Oct 17 at 13:18
  • it's an exercise. I have to transform the points in polygon with USING .. – fcka Oct 17 at 13:22
  • I run the query with pgadmin – fcka Oct 17 at 13:23
  • 1
    it's an excercise ha! now we know, and GIS.SE is no ghost writers guild ,) just so much: the POLYGON column type is a PostgreSQL data type... surely not what you are looking for... – ThingumaBob Oct 17 at 13:33
  • 1
    If this is a specific exercise, then more details outlining your intended process are needed. Otherwise I agree with Erik, there are several ways to do this if you're just wanting a result of points proportional to population. That can be done by symbology, Otherwise if you truly need to convert to a polygon feature you would use the GDAL buffer vectors process and set distance units proportional to your population ranges to get polygon data of different sizes. – Joshua A Oct 17 at 13:33
5

You are almost there with your query.

The issue is that polygon is a native Postgres data type that is not used by PostGIS. Instead, you will want to use the geometry type, which can be refined to contain only polygons geometry(polygon) or even for a specific projection (geometry(polygon,3857))

  • 1
    tss...now you spoiled the learning effect ,) – ThingumaBob Oct 17 at 13:49
  • 1
    To be honest, this postgres vs postgis data type could be explained much better in the doc. The mere existence of the PG geo types is questionable too, especially since PostGIS is a mature product with a very low footprint – JGH Oct 17 at 14:11
  • can't argue with that. – ThingumaBob Oct 17 at 14:39
3

Let's try to solve your problem with me :-), So you have a layer (table) with the name "city", which are represented as points with the name "points" with the type of geometry (Point, 2154) and a column with the name "pop" with the type of integer in which we store population data. If this is the case, let's move on, namely run the script:

create table city_pop as SELECT id, ST_Buffer (points, pop*0.01) geom_byffer, pop FROM city ORDER BY id;

As a result of the execution of the script we will get a new table with the name "city_pop", with the columns "id", "geom_byffer", "pop" where we have transferred the data from the source table and created buffer zones like Polygon with a ratio of 0.01.

Remember that in the new table you can leave the names of the columns as in the old table, or you can rename them at your discretion. You have to adjust the proportionality coefficient so that when you visualize your buffer zones you will be able to see them clearly.

Well, here we are all at the goal, believe in yourself, learn and further and do not be afraid of falling,

success to you...

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.