Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Once your datasets are loaded into PostgreSQL, Studio Workflow Stored Procedure Tasks can be used to run the geopivot functions. There are two:

  • at_wkf_geopivot_sum - this sums the point data sources within each polygonpolygon (from v6.0.0 this is called wkf_geopivot_sum under the -Workflow- Function filter)
  • at_wkf_geopivot_count - this counts the number of point data sources within each polygonpolygon (from v6.0.0 this is called wkf_geopivot_count under the -Workflow- Function filter)
Note

Note that the resulting output table names should be lower-case, this will prevent problems accessing the data from MapServer in the next step.

Sum Stored Procedure

This counts of all records for each distinct entry in a category column from one table for each area in another table.

at_wkf_geopivot_sum

...

at_ (wkf_geopivot_sum takes ) takes the following parameters:

ParameterTypeDescription
geometry_table_schemacharacter varyingThe schema where the geometry_table will be created - from v6.0.0
geometry_tablecharacter varyingThe table of polygons to use for the data aggregation, all the columns in this table will be replicated in the output table.
geometry_id_columncharacter varyingA column in geometry_table that uniquely identifies the records.
data_table_schemacharacter varyingThe schema where the data_table will be created - from v6.0.0
data_tablecharacter varyingThe table containing records with point geometry and category.
category_columncharacter varyingThe column in data_table to be used to categorize the data.
value_columncharacter varyingThe column in data_table containing the values to be summed.
output_table_schemacharacter varyingThe schema where the output_table will be created - from v6.0.0
output_tablecharacter varyingThe table to create with the summed and pivoted data, if it exists it will be dropped first.

Create a Stored Procedure Task in Studio and select the Function at_wkf_geopivot_sum (from v6.0.0 select wkf_geopivot_sum under the -Workflow- Function filter).

Here is a snapshot of the street crime data that we are using:

Image Added

Now select each parameter in turn to enter the values in the Edit parameter area e.g. Image Removedfor the Street Crime against Ward we will use the crime_type as the category to sum.

Image Added

If successful, the following is returned:

at_sys_geopivot_sum finished: table [output_table] created

The resulting table in this scenario looks like this:

Image Added

Once the table has been created this can be added as a Layer in Studio e.g.

Image Added

Now a Thematic can be applied and here we have selected to show how drugs crime is split across the Wards e.g.

Image Added

Count Stored Procedure

This counts of all records for each distinct entry in a category column from one table for each area in another table.

at_wkf_geopivot_count

...

at_  (wkf_geopivot_count takes  ) takes the following parameters:

ParameterTypeDescription
geometry_table_schemacharacter varyingThe schema where the geometry_table will be created - from v6.0.0
geometry_tablecharacter varyingThe table of polygons to use for the data aggregation, all the columns in this table will be replicated in the output table.
geometry_id_columncharacter varyingA column in geometry_table that uniquely identifies the records.
data_table_schemacharacter varyingThe schema where the data_table will be created - from v6.0.0
data_tablecharacter varyingThe table containing records with point geometry and category.
category_columncharacter varyingThe column in data_table to be used to categorize the data.
output_table_schemacharacter varyingThe schema where the output_table will be created - from v6.0.0
output_tablecharacter varyingThe table to create with the counted and pivoted data, if it exists it will be dropped first.

Create a Stored Procedure Task in Studio and select the Function at_wkf_geopivot_count (from v6.0.0 select wkf_geopivot_count under the -Workflow- Function filter).

As with at_wkf_geopivot_sum these parameters should be listed in comma-delimited form in Studio select each parameter in turn to enter the values in the Edit parameter area.

If successful, at_wkf_geopivot_count returns the following:

...

Your final table must contain a unique identifier, of data type SERIAL. This is generally called “ogc_fid”. If not already present, this can be added using a Studio Workflow another Stored Procedure Task that calls the function  Task, selecting the Workflow radio button and then select the at_sys_add_column e.g.

Image Removed

This stored procedure takes the following parameters as shown in the above screenshot:

...

wkf_executecmd entry from the list (from v6.0.0 this is called wkf_executecmd under the -Workflow- Function filter).

Click on Parameter 1. cmdtoexecute and enter the following.

Code Block
titleAdd ogc_fid column
alter table docs_geopivot_parish add column ogc_fid serial;