{"id":6051,"library":"pygeoif","title":"PyGeoIf","description":"PyGeoIf is a Python library providing a basic, pure-Python implementation of the `__geo_interface__` protocol. It enables the creation and manipulation of standard geospatial vector data types like Point, LineString, and Polygon, along with collections, making it suitable as a lightweight alternative to libraries like Shapely or as a foundation for building custom geospatial tools. The current version is 1.6.0, with an active release cadence, often aligning with Python version support changes and feature enhancements.","status":"active","version":"1.6.0","language":"en","source_language":"en","source_url":"https://github.com/cleder/pygeoif/","tags":["GIS","geospatial","geometry","geojson","geo_interface","WKT","vector-data"],"install":[{"cmd":"pip install pygeoif","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.9 or newer.","package":"python","optional":false}],"imports":[{"symbol":"Point","correct":"from pygeoif import Point"},{"symbol":"LineString","correct":"from pygeoif import LineString"},{"symbol":"Polygon","correct":"from pygeoif import Polygon"},{"symbol":"Feature","correct":"from pygeoif import Feature"},{"symbol":"FeatureCollection","correct":"from pygeoif import FeatureCollection"},{"symbol":"from_wkt","correct":"from pygeoif import from_wkt"},{"note":"The `as_shape` function was renamed to `shape` in version 1.0.0. The direct import from `pygeoif` is preferred.","wrong":"from pygeoif.geometry import as_shape","symbol":"shape","correct":"from pygeoif import shape"}],"quickstart":{"code":"from pygeoif import Point, LineString, Polygon, Feature, from_wkt\n\n# Create a Point\np = Point(1.0, -1.0)\nprint(f\"Point: {p}\")\nprint(f\"Point Geo Interface: {p.__geo_interface__}\")\n\n# Create a LineString\nl = LineString([(0, 0), (1, 1), (2, 0)])\nprint(f\"LineString: {l}\")\n\n# Create a Polygon with a hole\nexterior = [(0, 0), (0, 10), (10, 10), (10, 0), (0, 0)]\ninterior = [(2, 2), (2, 8), (8, 8), (8, 2), (2, 2)]\npoly = Polygon(exterior, [interior])\nprint(f\"Polygon: {poly.wkt}\")\n\n# Create a Feature with properties\nfeature_props = {'name': 'My Awesome Feature', 'id': 123}\nf = Feature(p, feature_props)\nprint(f\"Feature geometry type: {f.geometry.geom_type}\")\nprint(f\"Feature properties: {f.properties}\")\n\n# Create geometry from WKT\nwkt_point = from_wkt('POINT (5 10)')\nprint(f\"WKT Point: {wkt_point}\")","lang":"python","description":"This quickstart demonstrates how to create various geometry types (Point, LineString, Polygon), a Feature with properties, and how to import geometry from a Well-Known Text (WKT) string using `pygeoif`."},"warnings":[{"fix":"Ensure your project runs on Python 3.9 or newer when using pygeoif 1.6.0 or later. For older pygeoif versions, check their specific Python requirements.","message":"Python 2 support was removed, and the minimum required Python version has changed multiple times. Version 1.0.0 required Python >=3.7. Version 1.6.0 dropped support for Python 3.8, now requiring Python >=3.9.","severity":"breaking","affected_versions":"<1.0.0, 1.0.0-1.5.x"},{"fix":"Update imports from `from pygeoif.geometry import as_shape` to `from pygeoif import shape` and adjust calls accordingly.","message":"The `as_shape` function was renamed to `shape` in version 1.0.0 to align with Shapely's API. Direct import `from pygeoif import shape` is the modern approach.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Instead of modifying existing geometry objects, create new ones with the desired changes. For example, `new_point = Point(x + 1, y)` instead of `point.x += 1`.","message":"Geometries became immutable in version 1.2.0. Attempting to modify attributes of a geometry object (e.g., coordinates of a Point) directly will raise an error.","severity":"breaking","affected_versions":"<1.2.0"},{"fix":"If migrating from or interoperating with Shapely, thoroughly test your code with pygeoif, especially around geometry validation and complex operations. Consult both libraries' documentation for specific behavior details.","message":"While pygeoif implements the `__geo_interface__` protocol similarly to Shapely, their internal behavior for certain edge cases (e.g., validity checks, operations on degenerate geometries) can differ. This can lead to unexpected results if switching between libraries without thorough testing.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When exchanging data with other GIS tools or formats, be mindful that `GeometryCollection` objects might not be directly ingestible and may require decomposition into simpler geometry types.","message":"`GeometryCollection` is part of the GeoJSON specification but is not universally supported across all GIS software or file formats (e.g., Shapefile).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}