{"id":34100161,"url":"https://github.com/campiohe/geomask","last_synced_at":"2025-12-30T16:12:14.268Z","repository":{"id":236143115,"uuid":"769324146","full_name":"campiohe/geomask","owner":"campiohe","description":"A very simple lib for creating geometric masks from spatial data using regular grids.","archived":false,"fork":false,"pushed_at":"2025-09-24T22:49:13.000Z","size":14079,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-25T00:23:17.197Z","etag":null,"topics":["climate","data","gis","weather"],"latest_commit_sha":null,"homepage":"","language":"Python","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/campiohe.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-08T20:08:20.000Z","updated_at":"2025-09-15T00:07:08.000Z","dependencies_parsed_at":"2024-05-15T17:35:47.173Z","dependency_job_id":"561a078d-ae68-4074-904d-ff4732e5ac19","html_url":"https://github.com/campiohe/geomask","commit_stats":null,"previous_names":["sr-henry/geo-mask","campiohe/geo-mask","campiohe/geomask"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/campiohe/geomask","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/campiohe%2Fgeomask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/campiohe%2Fgeomask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/campiohe%2Fgeomask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/campiohe%2Fgeomask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/campiohe","download_url":"https://codeload.github.com/campiohe/geomask/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/campiohe%2Fgeomask/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27731498,"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","status":"online","status_checked_at":"2025-12-14T02:00:11.348Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["climate","data","gis","weather"],"created_at":"2025-12-14T16:43:29.053Z","updated_at":"2025-12-14T16:43:31.501Z","avatar_url":"https://github.com/campiohe.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GeoMask\n\nA very simple lib for creating geometric masks from spatial data using regular grids.\n\n## Features\n\n- Create regular grids of points inside spacial geometries (polygons or multipolygons)\n- Control grid spacing with a resolution parameter\n- Optional point limits to avoid huge grids\n- Export to pandas DataFrames\n\n## Installation\n\n```bash\npip install geomask\n```\n\n## Quick Start\n\n```python\nfrom geomask import GeoMask\nfrom shapely import Polygon\n\n# Create a polygon\npolygon = Polygon([(0, 0), (10, 0), (10, 10), (0, 10)])\n\n# Generate a grid mask\nmask = GeoMask(geom=polygon, resolution=1.0)\n\nprint(f\"Generated {len(mask)} points\")\nprint(f\"Area: {mask.area}\")\nprint(f\"Bounds: {mask.bounds}\")\n```\n\n## Core Functionality\n\n### Creating Masks\n\n```python\nfrom geomask import GeoMask\nfrom shapely import Polygon, MultiPolygon\n\n# Basic usage\npolygon = Polygon([(0, 0), (10, 0), (10, 10), (0, 10)])\nmask = GeoMask(geom=polygon, resolution=2.0)\n\n# With point limit\nmask = GeoMask(geom=polygon, resolution=0.5, limit=100)\n\n# With grid offset\nmask = GeoMask(geom=polygon, resolution=1.0, offset=(0.5, 0.5))\n\n# Works with MultiPolygons too\npoly1 = Polygon([(0, 0), (5, 0), (5, 5), (0, 5)])\npoly2 = Polygon([(10, 10), (15, 10), (15, 15), (10, 15)])\nmultipoly = MultiPolygon([poly1, poly2])\nmask = GeoMask(geom=multipoly, resolution=1.0)\n```\n\n### Extracting Coordinates\n\n```python\n# As numpy array\ncoords = mask.to_coordinates()\nprint(f\"Shape: {coords.shape}\")  # (n_points, 2)\n\n# As pandas DataFrame (requires pandas)\ndf = mask.to_dataframe()\nprint(df.head())\n\n# Custom column names\ndf = mask.to_dataframe(x_col='longitude', y_col='latitude')\ndf = mask.to_dataframe(x_col='easting', y_col='northing')\n```\n\n### Filtering and Analysis\n\n```python\n# Filter by another geometry\nfilter_polygon = Polygon([(2, 2), (8, 2), (8, 8), (2, 8)])\nfiltered_mask = mask.filter_by_geometry(filter_polygon)\n\n# Properties and methods\nprint(f\"Point count: {len(mask)}\")\nprint(f\"Has points: {bool(mask)}\")\nprint(f\"Area: {mask.area}\")\nprint(f\"Bounds: {mask.bounds}\")\n```\n\n### Integration with Pandas\n\n```python\nimport pandas as pd\nimport numpy as np\n\n# Convert to DataFrame for analysis\ndf = mask.to_dataframe(x_col='x', y_col='y')\n\n# Add computed columns\ndf['distance_from_origin'] = np.sqrt(df.x**2 + df.y**2)\ndf['quadrant'] = df.apply(\n    lambda row: ('N' if row.y \u003e= 0 else 'S') + ('E' if row.x \u003e= 0 else 'W'), \n    axis=1\n)\n\n# Analysis\nprint(df.describe())\nprint(df.quadrant.value_counts())\n\n# Filter points\nclose_points = df[df.distance_from_origin \u003c 5.0]\n```\n\n## Advanced Usage\n\n### Working with Complex Geometries\n\n```python\n# Polygon with hole\nouter = [(0, 0), (10, 0), (10, 10), (0, 10), (0, 0)]\ninner = [(3, 3), (7, 3), (7, 7), (3, 7), (3, 3)]\npolygon_with_hole = Polygon(outer, [inner])\n\nmask = GeoMask(geom=polygon_with_hole, resolution=1.0)\n```\n\n### Performance Optimization\n\n```python\n# Use limits for large areas\nlarge_polygon = Polygon([(0, 0), (1000, 0), (1000, 1000), (0, 1000)])\n\n# This will automatically adjust resolution to meet the limit\nmask = GeoMask(geom=large_polygon, resolution=1.0, limit=10000)\nprint(f\"Actual resolution used: {mask.resolution}\")\n```\n\n## Requirements\n\n- Python 3.11+\n- shapely \u003e= 2.1.1\n- numpy\n- pandas (optional, for DataFrame functionality)\n\n## Development\n\n### Testing\n\nRun the comprehensive test suite:\n\n```bash\n# Basic tests\npytest test_geomask.py\n\n# With coverage\npytest test_geomask.py --cov=geomask --cov-report=term-missing\n\n# Verbose output\npytest test_geomask.py -v\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcampiohe%2Fgeomask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcampiohe%2Fgeomask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcampiohe%2Fgeomask/lists"}