[postgis-users] Calculating Attributes

Paul Ramsey pramsey at opengeo.org
Fri Apr 3 10:24:11 PDT 2009


Philosophical point:

Creating a column and filling it with a property of GEOMETRY like
ST_Area() or ST_Length() is something which makes sense in a legacy
GIS like Arc* or GRASS, where attributes are handled separately from
spatial. In a spatial database, where the GEOMETRY is co-equal to the
other columns, there is not much point, unless you are doing it for
export purposes (filling in a column before exporting to shapefile for
consumption by a legacy GIS).

What does having AREA in a column gain you? Now you can do math and
tests against it? Well, in database land, you can do that already,
just do you math and tests against the ST_Area() function directly.

Paul

2009/4/3 George Silva <georger.silva at gmail.com>:
> Hello Aurora,
>
> In ArcGIS it's all different. In PostGIS you can use simple/complex SQL
> queries to "calculate values" in a similar fashion of arcgis.
>
> The simplest of them all would be, in your case:
>
> ALTER TABLE table1 ADD COLUMN area_column double precision;
> UPDATE table1 SET area_column = ST_AREA(the_geom);
>
> You can in that SQL query divide, multiply, and do whatever you want with
> that result that will be written to the column area_column.
>
> I hope that helps
>
> George
>
> On Fri, Apr 3, 2009 at 12:55 PM, Aurora Geomatics
> <aurorageomatics at gmail.com> wrote:
>>
>> Hello PostGIS users,
>>
>> I have just installed William Kyng's PostgeSQ/PostGIS packages for Mac OS
>> X.5
>>
>> I have been playing with pgAdmin and QGIS with importing shapefiles into
>> PostGIS.  Works dandy.
>>
>> Now I am wondering how to solve Attribute Calculations.
>>
>> Years of using ArcGIS and GRASS it is pretty straightforward on those
>> apps, and am stumped with PostGIS Attribute calculations..
>>
>> For example, using a polygon feature;
>>
>> Creating a new column, say AREA and filling with a calculation that is
>> Hectares.
>>
>> Thanks!
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>



More information about the postgis-users mailing list