VectorTableJoiner

Joins the fields of a table, a dbf file or the attribute table of another vector, to the features of a vector, by a common field, as the population of a census table to the municipalities by their code.

Details

Each feature takes the joined fields of the first row of the table with the same value of the common field, which can have different names in the vector and in the table, as basin_id,id. The values are matched as text, so a whole number matches also when it is stored as an integer in one source and as a decimal number or a text in the other, as 12, 12.0 and “12”; texts are matched without the spaces at their ends. Each joined field takes the type of its first value in the table.

It is an inner join: the features without a matching row are left out, and their number is reported. The joined fields are added to the ones of the vector, so they must have names that the vector doesn’t have yet. In a shapefile the names are cut to 10 characters.

Parameters

Joins the fields of a table to the features of a vector with the same value in a common field.

Toolbox folder: Vector Processing
Status: Certified
Keywords: Join, Vector, Table, Attributes
Authors: Andrea Antonello
Class: org.hortonmachine.modules.VectorTableJoiner

Inputs

Parameter

Type

Unit

Default

Description

inVector

vector file

The vector to extend.

inTable

file

The table to join: a dbf file or the attribute table of a vector.

fCommon

String

The common field or, if it has different names in the two sources, the two names separated by a comma, first the one of the vector, then the one of the table.

pFields

String

The comma separated list of the fields of the table to join.

Outputs

Parameter

Type

Unit

Description

outVector

output file

The joined vector.

Example

The example makes a table with the mean slope of each sub-basin of BasinShape, with RasterCatToFeatureAttribute on the slope of Slope, and joins it, by the number of the sub-basin, to their centroids of the DelaunayTriangulation example:

import org.hortonmachine.modules.RasterCatToFeatureAttribute
import org.hortonmachine.modules.VectorTableJoiner

// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"

// a table with the mean slope of each sub-basin, by netnum: the dbf of the
// sub-basins of BasinShape with the statistics of the slope of Slope
var rat2feature = new RasterCatToFeatureAttribute()
rat2feature.inRaster = folder + "slope.tif"
rat2feature.inVector = folder + "subbasins.shp"
rat2feature.fNew = "slope"
rat2feature.outVector = folder + "subbasins_slope.shp"
rat2feature.process()

var joiner = new VectorTableJoiner()
// the centroids of the sub-basins, of the DelaunayTriangulation example
joiner.inVector = folder + "subbasins_centroids.shp"
joiner.inTable = folder + "subbasins_slope.dbf"
joiner.fCommon = "netnum"
joiner.pFields = "slope_avg"
joiner.outVector = folder + "subbasins_centroids_slope.shp"
joiner.process()

The first centroids, with the joined slope, in m/m:

netnum

avgelev

slope_avg

1

2009.0

0.526

2

2099.7

0.534

3

2088.0

0.592