Versions Compared

Key

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

This tool provides basic spatial functions for processing a CSV files with WKT geometries. You can calculate interesection, buffer, bounding box, area, dissolve, difference and so on. It is build on top of Spatialite and thanks to it has very low memory footprint and it is even ready for large datasets (millions of rows). This tool could be handy if you dont have PostGIS or similar tools available.

SpatialUtils is CSV based (input and output). There are some requirements for geometries:

If your data is in other format than CSV with WKT (e.g. Shapefile, GeoJSON), you can convert it using for example ogr2ogr utility (https://gdal.org/drivers/vector/csv.html).

Spatial functions

You can use one of the following spatial function in each execution of SpatialUtils:

  • area
    • computes area in square meters for each polygon
    • value for function parameter in configuration is area
  • bounding box
    • computes x_min, x_max, y_min and y_max for each geometry
    • value for function parameter in configuration is bbox 
  • buffer
    • computes buffer around geometry (point, line, polygon) with defined radius in meters
    • value for function parameter in configuration is buffer
  • centroid
    • computes a centroid point for each geometry
    • value for function parameter in configuration is centroid
  • union
    • computes an union of geometries based on same values of attribute key 
    • value for function parameter in configuration is union
  • intersection
    • computes an intersection between geometries from two input tables 
    • value for function parameter in configuration is intersection
  • isvalid
    • validates WKT geometries and writes result into a two new columns - isvalid and isvalid_reason
    • value for function parameter in configuration is isvalid


You can check for example https://postgis.net/workshops/postgis-intro/geometry_returning.html for further information about spatial functions.

Installation

SpatialUtils is available as Keboola Connection Component and it is available to registered Keboola users. You have to be logged in your Keboola project (https://connection.keboola.com) to use it. To open SpatialUtils just go to Applications, choose New Application and write "SpatialUtils" into the search bar. Then choose CleverMaps SpatialUtils

Configuration

With the SpatialUtils application opened, choose New Configuration and fill in the form.

...

Secondly you need to pass a configuration JSON into SpatialUtils. Please check the examples below to get the idea how the configuration file should look.


Code Block
{
  "function": "area",
  "in_csv": {
    "wkt_column_name": "geom",
    "out_columns": [
      "zone_id"
    ]
  }
}

...