{"id":19074282,"url":"https://github.com/postlagerkarte/geohash-dotnet","last_synced_at":"2025-06-21T21:35:09.411Z","repository":{"id":48568921,"uuid":"196592485","full_name":"Postlagerkarte/geohash-dotnet","owner":"Postlagerkarte","description":"Easy-to-use and feature-rich geohash library written in C# |  Encode \u0026 Decode of Geohashes | Converts a polygon into a set of geohashes with arbitrary precision | Allows Geohash Compression","archived":false,"fork":false,"pushed_at":"2024-12-11T21:03:03.000Z","size":1738,"stargazers_count":87,"open_issues_count":1,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T04:47:40.294Z","etag":null,"topics":["csharp","geohash","geohash-algorithm","geohash-library","longitude-and-latitude","polygon"],"latest_commit_sha":null,"homepage":"","language":"C#","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/Postlagerkarte.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-12T14:23:01.000Z","updated_at":"2025-03-04T20:59:59.000Z","dependencies_parsed_at":"2024-06-18T17:08:02.625Z","dependency_job_id":"d1e0778b-2043-4889-8a47-d86e5219fdd5","html_url":"https://github.com/Postlagerkarte/geohash-dotnet","commit_stats":{"total_commits":73,"total_committers":2,"mean_commits":36.5,"dds":0.0547945205479452,"last_synced_commit":"32b4a5842d4f326608f1b78ddb33ba08e3e0911c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Postlagerkarte%2Fgeohash-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Postlagerkarte%2Fgeohash-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Postlagerkarte%2Fgeohash-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Postlagerkarte%2Fgeohash-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Postlagerkarte","download_url":"https://codeload.github.com/Postlagerkarte/geohash-dotnet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254465389,"owners_count":22075659,"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":["csharp","geohash","geohash-algorithm","geohash-library","longitude-and-latitude","polygon"],"created_at":"2024-11-09T01:50:21.570Z","updated_at":"2025-05-16T08:02:45.716Z","avatar_url":"https://github.com/Postlagerkarte.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# geohash-dotnet \u003cimg src=\"https://github.com/postlagerkarte/geohash-dotnet/raw/master/icon.png\" width=\"32\" height=\"32\" /\u003e\nAn easy-to-use, feature-rich geohash library for .NET\n\n## Installation\n\nInstall via NuGet Package Manager:\n\n ```\n  Install-Package geohash-dotnet\n ```\n[![NuGet version (blazor-dragdrop)](https://img.shields.io/nuget/v/geohash-dotnet.svg?style=flat-square)](https://www.nuget.org/packages/geohash-dotnet) [![Nuget](https://img.shields.io/nuget/dt/geohash-dotnet)](https://www.nuget.org/packages/geohash-dotnet)\n\n## Features\n### Geohasher\n- Encode/Decode: Convert between geographic coordinates and geohash strings.\n- Neighbors: Find adjacent geohashes in all cardinal directions.\n- Subhashes: Retrieve finer-grained geohashes within a parent geohash.\n- Parent Geohash: Get the less precise parent of a given geohash.\n- Bounding Box: Obtain the geographic bounding box of a geohash.\n\n### PolygonHasher\n- Generate geohashes within a specified polygon based on precision and inclusion criteria.\n- Ideal for spatial indexing and geospatial queries within complex areas.\n\n### GeohashCompressor\n- Compresses a set of geohashes to a minimal set that still covers the same area.\n- Optimizes storage and improves performance for spatial queries.\n\n\n## Geohasher\nGenerate geohashes that cover a specific polygon:\n  ```csharp\n// Create a new Geohasher instance\nvar geohasher = new Geohasher();\n\n// Encode latitude and longitude into a geohash string\nstring geohash = geohasher.Encode(37.4219999, -122.0840575, 9);\n\n// Decode the geohash back to latitude and longitude\n(double latitude, double longitude) = geohasher.Decode(geohash);\n\n// Get subhashes of a geohash\nstring[] subhashes = geohasher.GetSubhashes(geohash);\n\n// Get neighbors of a geohash\nDictionary\u003cDirection, string\u003e neighbors = geohasher.GetNeighbors(geohash);\n\n// Get parent of a geohash\nstring parent = geohasher.GetParent(geohash);\n\n// Get the bounding box of a geohash\nBoundingBox bbox = geohasher.GetBoundingBox(geohash);\n ```\n\n## PolygonHasher\n  ```csharp\n\n// Initialize PolygonHasher\nvar polygonHasher = new PolygonHasher();\n\n// Define a polygon\nPolygon polygon = new Polygon(new LinearRing(new Coordinate[] {\n    new Coordinate(-122.4183, 37.7755),\n    new Coordinate(-122.4183, 37.7814),\n    new Coordinate(-122.4085, 37.7814),\n    new Coordinate(-122.4085, 37.7755),\n    new Coordinate(-122.4183, 37.7755) // Closing the ring\n}));\n\n// Get geohashes of precision 6 that intersect with the polygon\nvar geohashes = polygonHasher.GetHashes(polygon, 6, PolygonHasher.GeohashInclusionCriteria.Intersects);\n\n// Output the geohashes\nforeach (string hash in geohashes)\n{\n    Console.WriteLine(hash);\n}\n```\n\n## GeohashCompressor\nCompress a list of geohashes into a minimal covering set:\n  ```csharp\n// Initialize GeohashCompressor\nvar compressor = new GeohashCompressor();\n\n// Define input geohashes\nvar inputGeohashes = new[] {\n    \"tdnu20\", \"tdnu21\", \"tdnu22\", \"tdnu23\", \"tdnu24\", \"tdnu25\",\n    \"tdnu26\", \"tdnu27\", \"tdnu28\", \"tdnu29\", \"tdnu2b\", \"tdnu2c\",\n    // ... additional geohashes\n};\n\n// Compress the geohashes\nvar compressedGeohashes = compressor.Compress(inputGeohashes);\n\n// Output the compressed geohashes\nforeach (var hash in compressedGeohashes)\n{\n    Console.WriteLine(hash);\n}\n  ```\n\n### Finding Neighbors\n\n![](https://github.com/Postlagerkarte/geohash-dotnet/blob/51ef3c07c1a321ac3994a848c3315fb4a3a971f8/neighbors.gif)\n\n\n  ```csharp\nDictionary\u003cDirection, string\u003e neighbors = geohasher.GetNeighbors(geohash);\n ```\n\n  ```csharp\nstring northNeighbor = neighbors[Direction.North];\nstring southNeighbor = neighbors[Direction.South];\n// ... and so on for the other directions\n ```\n \nfind the neighbor hash in a specific direction, use the GetNeighbor() method:\n\n  ```csharp\nstring northNeighbor = geohasher.GetNeighbor(geohash, Direction.North);\n ```\n \n### Subhashes\nSubhashes represent smaller, equally-sized regions within a geohash's bounding box:\n  ```csharp\nstring[] subhashes = geohasher.GetSubhashes(geohash);\n ```\n### Parent Geohash\nThe parent of a geohash is the geohash that covers the same area but at a lower precision level:\n  ```csharp\nstring parent = geohasher.GetParent(geohash);\n ```\nKeep in mind that the parent geohash will be less precise and cover a larger area.\n\n### Bounding Box\nTo obtain the bounding box (minimum and maximum latitude and longitude):\n  ```csharp\nBoundingBox bbox = geohasher.GetBoundingBox(geohash);\n ```\n\n\n### Performance Notes\nPolygonHasher and GeohashCompressor have a time complexity of O(N²) relative to the number of geohashes processed.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostlagerkarte%2Fgeohash-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostlagerkarte%2Fgeohash-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostlagerkarte%2Fgeohash-dotnet/lists"}