Carto Tools
is a C++ application for performing geospatial tasks on GeoJSON files, such as intersection reports, GeoJSON similarity calculations, and area error calculations.
Before building the project, ensure you have the following software installed:
brew install cmake make boost
sudo apt update
sudo apt install cmake make libboost-all-dev
Build the Docker image using the provided Dockerfile
:
docker build -t carto-tools .
Create and run the Docker container with Volume Mounting:
docker run -it --name carto-container -v $(pwd):/app carto-tools
For consecutive runs, start the container:
docker start -ai carto-container
To build and install the project, navigate to the project directory and use the following single command:
cmake -B build && make -C build && make install -C build
The application supports multiple tasks via command-line arguments. Below are the available commands:
Generate a report of intersections in a GeoJSON file. The report includes:
- The number of self-intersections.
- The number of intersections with other polygons. (overlapping polygons intersections)
- SVG visualization of the intersections (if any).
carto --intersection --map <geojson_file>
Example:
carto --intersection --map ./data/belgium/belgium_intersections.geojson
Calculate similarity metrics (Frechet Distance, Hausdorff Distance, and Symmetric Difference) between two GeoJSON files.
Both GeoJSON files must share at least one common property within their features (shared identifier, name). For example, the two files could represent the same map before and after a cartogram transformation, such as one generated at go-cart.io.
carto --similarity --map_1 <geojson_file_1> --map_2 <geojson_file_2>
Example:
carto --similarity --map_1 ./data/belgium/belgium.geojson --map_2 ./data/belgium/belgium_cartogram.geojson
Calculate the Max Relative Area Error and the Area Weighted Mean Error of a GeoJSON file compared to a target area CSV file. The target area CSV file template can be generated using the --create_csv
command described below. Simply fill in the empty column with the target area values.
carto --area_error --map <geojson_file> --target_area_csv <csv_file>
Example:
carto --area_error --map ./data/belgium/belgium_cartogram.geojson --target_area_csv ./data/belgium/belgium_population.csv
Generate a CSV file template for target area values. The CSV file will contain one column that is empty for the user to fill in the target area values. The completed CSV file can be used as input for the --area_error
command.
carto --create_csv --map <geojson_file>
Example:
carto --create_csv --map ./data/belgium/belgium.geojson
If you encounter any problems, have feature requests, or have suggestions, please create an issue in the repository.
This project is licensed under the MIT License.