Overview
The CSV module helps in handling the common case where you have a common geometry layer and multiple sets of alfanumeric data in CSV format that refer to it thru a shared key. You want to map the alphanumeric data against the geometries, without duplicating the geometries.
The common approach is to:
- load the geometry layer into a spatial database
- load the csv file as a table in the same spatial database
- build one or more views joining the two
- registering the views in GeoServer so they are available for mapping
The CSV module automates the process using a PostGIS backend and a REST api allowing the user to upload a CSV file, dump it into the database, create the views and register everything against GeoServer configuration for usage. Coupled with other community modules such as RestConfig and SLDService it allows to build a thematic mapping platform.
Configuration
The CSV module only needs to know which PostGIS datastore to use in order to function properly.
This configuration is provided by means of a property file in the data directory: $GEOSERVER_DATA_DIR/csv/csv.properties.
The property file should contain a single line:
datastore=<name of the datastore>
REST API
| URL | GET | DELETE | PUT | POST |
|---|---|---|---|---|
| /rest/csv/geometryLayers | list of target geometric layer names | |||
| /rest/csv/dataLayers | list of layer names | post a csv file + target geometric layer name to have all the new layers created, returns a list of the names for the layers created | ||
| /rest/csv/dataLayers/{layerName} | layer long name | removes the layer and all associated styles | ||
| /csv/tileLayers | retrieves a capabilities like document for the tiles (assuming you're publishing the same layers with GeoWebCache |
Structure of CSV files
The CSV files have to be properly structured in order to be uploadable, in particular:
"Long name one","Long name two",... "shortNameOne","shortNameTwo",... "type1","type2","type3",... value1,value2,...
where the long name can be used as a user label, the short name is used to create the database column name, and the type can be "string","integer" or "float".
After the upload the module will create one table per column in the csv file, and one joining view per table. This allows to update or drop single columns without affecting the others (in the case where the number of records differ), thought of course it increases the number of trables around significantly.