{"id":19558677,"url":"https://github.com/jblindsay/go-spatial","last_synced_at":"2025-04-26T23:32:05.825Z","repository":{"id":35852895,"uuid":"40137270","full_name":"jblindsay/go-spatial","owner":"jblindsay","description":"GoSpatial is a simple command-line interface program for manipulating geospatial data","archived":false,"fork":false,"pushed_at":"2018-04-24T20:40:17.000Z","size":15170,"stargazers_count":64,"open_issues_count":3,"forks_count":8,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-04T18:22:13.297Z","etag":null,"topics":["geographical-information-system","gis","manipulating-geospatial-data","spatial-analysis"],"latest_commit_sha":null,"homepage":"http://www.uoguelph.ca/~hydrogeo/software.shtml","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jblindsay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-03T17:04:28.000Z","updated_at":"2024-12-15T16:11:34.000Z","dependencies_parsed_at":"2022-09-26T17:50:42.017Z","dependency_job_id":null,"html_url":"https://github.com/jblindsay/go-spatial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jblindsay%2Fgo-spatial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jblindsay%2Fgo-spatial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jblindsay%2Fgo-spatial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jblindsay%2Fgo-spatial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jblindsay","download_url":"https://codeload.github.com/jblindsay/go-spatial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251068039,"owners_count":21531475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geographical-information-system","gis","manipulating-geospatial-data","spatial-analysis"],"created_at":"2024-11-11T04:47:49.622Z","updated_at":"2025-04-26T23:32:05.433Z","avatar_url":"https://github.com/jblindsay.png","language":"Go","funding_links":[],"categories":["Geospatial Library","Go"],"sub_categories":["Go"],"readme":"# GoSpatial\n\n## Warning\n\nThis project was developed during a period when I was experimenting with different alternatives to Java for developing Whitebox GAT. I have now settled on the Rust programming language for future development efforts. The tools that are contained within the GoSpatial codebase have since been ported to [WhiteboxTools](http://www.uoguelph.ca/~hydrogeo/WhiteboxTools/index.html). This project is being maintained for archival purposes only.\n\n## Description\n\nGoSpatial is a command-line interface program for analyzing and manipulating geospatial data. It has been developed by [John Lindsay](http://www.uoguelph.ca/geography/faculty/lindsay-john \"John Lindsay's homepage\") using the [Go](https://golang.org \"Go programming language homepage\") programming language and is compiled to native code. The project is experimental and is intended to provide additional analytical support for the [Whitebox Geospatial Analysis Tools](http://www.uoguelph.ca/~hydrogeo/Whitebox/ \"Whitebox GAT homepage\") open-source GIS software. GoSpatial can however run completely independently of any other software. Visit the GoSpatial homepage [here](http://www.uoguelph.ca/~hydrogeo/software.shtml).\n\n## Install\n\nTo install the GoSpatial source code using the ```go get``` tool within the terminal, simply type:\n\n```\ngo get github.com/jblindsay/go-spatial\n```\n\nYou may then build an executable file using the ```go build``` tool. Alternatively, you may call the *build.py* script, although [Go](https://golang.org) must be installed on the host computer.\n\n**Pre-compiled versions** of the GoSpatial executable are available for various supported platforms and are distributed from the [Centre for Hydrogeomatics](http://www.uoguelph.ca/~hydrogeo/software.shtml \"Centre for Hydrogeomatics homepage\") homepage.\n\n## Usage\n\n### Getting help\n\nTo print a list of commands for GoSpatial, simply use the ```help``` command:\n\n```\n*************************\n* Welcome to GoSpatial! *\n*************************\nPlease enter a command: help\nThe following commands are recognized:\nbench           Prints the current benchmarking mode\nbenchoff        Turns benchmarking mode off\nbenchon         Turns benchmarking mode on. Note: not all tools support this\nclear           Clears the screen (also 'c', 'cls', or 'clr')\ncwd             Changes the working directory (also 'cd' or 'dir'),\n                 e.g. cwd /Users/john/\nexit            Exits GoSpatial (also 'logout' or 'esc')\nhelp            Prints a list of available commands (also 'h')\nlicence         Prints the licence\nlisttools       Lists all available tools\nmemprof         Outputs a memory usage profile\npwd             Prints the working directory (also 'dir')\nrasterformats   Prints the supported raster formats\nrun             Runs a specified tool (also 'r'),\n                 e.g. run toolname  or  run toolname \"arg1;arg2;arg3;...\"\ntoolargs        Prints the argument descriptions for a tool\ntoolhelp        Prints help documentation for a tool,\n                 e.g. toolhelp BreachDepressions\nversion         Prints version information (also 'v')\nPlease enter a command:\n```\n\nThe most common command that you will use is the ```run``` command.\n\n### Working directories\nTo print the current working directory, use the ```pwd``` command:\n```\nPlease enter a command: pwd\nWorking directory: /Users/johnlindsay/Documents/Data/\n```\n\nTo change the working directory, use the ```cwd``` command:\n```\nPlease enter a command: cwd /Users/johnlinsay/Documents/data\n```\n\n### Tools\n\nTo print a list of available tools, use the ```listtools``` command:\n```\nPlease enter a command: listtools\nThe following 15 tools are available:\nAspect               Calculates aspect from a DEM\nBreachDepressions    Removes depressions in DEMs using selective breaching\nD8FlowAccumulation   Performs D8 flow accumulation on a DEM\nDeviationFromMean    Calculates the deviation from mean\nElevationPercentile  Calculates the local elevation percentile for a DEM\nFD8FlowAccum         Performs FD8 flow accumulation on a DEM\nFillDepressions      Removes depressions in DEMs using filling\nFillSmallNodataHoles Fills small nodata holes in a raster\nHillshade            Calculates a hillshade raster from a DEM\nMaxElevationDeviatio Calculates the maximum elevation deviation across a ran\nPrintGeoTiffTags     Prints a GeoTiff's tags\nPrintLASInfo         Prints details of a LAS file\nQuantiles            Tranforms raster values into quantiles\nSlope                Calculates slope from a DEM\nWhitebox2GeoTiff     Converts Whitebox GAT raster to GeoTiff\n```\n\nTo run a tool from the command-line interface, use the ```run``` command:\n\n```\nPlease enter a command: run BreachDepressions\n*********************\n* breachdepressions *\n*********************\nEnter the DEM file name (incl. file extension):\n```\n\nWhen you run a tool from the command-line interface, you will be guided in terms of the input of the arguments required to run the tool. When you are prompted for an input file name (as in the above example), if the file resides in the current working directory, you can omit the directory from the file name. If you would like to print a list of arguments needed to run a particular plugin tool, with descriptions, use the ```toolargs``` command:\n\n```\nPlease enter a command: toolargs breachdepressions\nThe following arguments are listed for 'breachdepressions':\nInputDEM               string    The input DEM name with file extension\nOutputFile             string    The output filename with file extension\nMaxDepth               float64   The maximum breach channel depth (-1 to ignore)\nMaxLength              int       The maximum length of a breach channel (-1 to ignore)\nConstrainedBreaching   bool      Use constrained breaching?\nSubsequentFilling      bool      Perform post-breach filling?\nPlease enter a command:\n```\n\nThis can be helpful when you want to execute a GoSpatial and run a tool by specifying flags and arguments. In the example below, after ```cd```ing to the directory containing the go-spatial executable file, it is possible to run a specific tool (```filldepressions```), providing the arguments for the ```-cwd```, ```-run```, and ```-args``` flags:\n\n```\n$ ./go-spatial -cwd=\"/Users/jlindsay/data/\" -run=\"filldepressions\" -args=\"my DEM.dep;outputDEM.tif;true\"\n*******************\n* filldepressions *\n*******************\nReading DEM data...\nFilling DEM (2 of 2): 100%\nOperation complete!\nElapsed time (excluding file I/O): 5.449522954s\nElapsed time (total): 6.087567077s\n$\n```\n\n### Calling GoSpatial tools from a script\n\nSometimes you need to call a GoSpatial tool in an automated fashion, rather than using the GoSpatial command-line interface. Here is an example (*gospatial_example.py* in source folder) of interacting with the GoSpatial library from a Python script:\n\n```python\n#!/usr/bin/env python\nimport sys\nimport gospatial as gs\n\ndef main():\n    try:\n        # List all available tools in gospatial\n        print(gs.list_tools())\n\n        # Prints the gospatial help...a listing of available commands\n        print(gs.help())\n\n        # Print the help documentation for the Aspect tool\n        print(gs.tool_help(\"Aspect\"))\n\n        # Prints the arguments used for running the FillDepressions tool\n        print(gs.tool_args(\"FillDepressions\"))\n\n        # Run the Aspect tool, specifying the arguments.\n        name = \"Aspect\"\n        args = [\n            \"DEM no OTOs.dep\",\n            \"aspect.dep\"\n        ]\n\n        # Run the tool and check the return value\n        ret = gs.run_tool(name, args, cb)\n        if ret != 0:\n            print(\"ERROR: return value={}\".format(ret))\n\n    except:\n        print(\"Unexpected error:\", sys.exc_info()[0])\n        raise\n\n# Create a custom callback to process the text coming out of the tool.\n# If a callback is not provided, it will simply print the output stream.\ndef cb(s):\n    if \"%\" in s:\n        str_array = s.split(\" \")\n        label = s.replace(str_array[len(str_array)-1], \"\")\n        progress = int(str_array[len(str_array)-1].replace(\"%\", \"\").strip())\n        print(\"\\rProgress: {}%\".format(progress)),\n    else:\n        if \"error\" in s.lower():\n            print(\"\\rERROR: {}\".format(s)),\n        else:\n            if not s.startswith(\"*\"):\n                print(\"\\r{}          \".format(s)),\n\nmain()\n```\n\nThe code above uses the *gospatial.py* helper script, also found in the source folder.\n\n\u003c!-- ```python\n#! /usr/bin/env python3\nimport subprocess\n\nexecutablestr = \"/Users/me/Projects/go-spatial\"\nworkdir = \"/Users/me/Documents/data/\"\ntoolname = \"filldepressions\"\nargs = \"my DEM.dep;outputDEM.tif;true\"\n\na = [executablestr, \"-cwd\", workdir, \"-run\", toolname, \"-args\", args]\n\nprint(\"Setting up process...\")\np = subprocess.Popen(a)\nprint(\"Running process...\")\np.wait()\nprint(\"Done!\")\n``` --\u003e\n\n## License\n\nGoSpatial is distributed under the [MIT open-source license](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjblindsay%2Fgo-spatial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjblindsay%2Fgo-spatial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjblindsay%2Fgo-spatial/lists"}