Skip to main content
Glama

snap_geometry

Align one geometry to another by snapping it within a specified tolerance using shapely.ops.snap on the GIS MCP Server, returning the snapped geometry as a WKT string.

Instructions

Snap one geometry to another using shapely.ops.snap. Args: geometry1: WKT string of the geometry to be snapped. geometry2: WKT string of the reference geometry. tolerance: Distance tolerance for snapping. Returns: Dictionary with status, message, and snapped geometry as WKT.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geometry1Yes
geometry2Yes
toleranceYes

Implementation Reference

  • The main handler function for the 'snap_geometry' tool, which snaps one Shapely geometry to another using a specified tolerance via shapely.ops.snap. Inputs are WKT strings, output includes the resulting WKT geometry.
    @gis_mcp.tool() def snap_geometry(geometry1: str, geometry2: str, tolerance: float) -> Dict[str, Any]: """ Snap one geometry to another using shapely.ops.snap. Args: geometry1: WKT string of the geometry to be snapped. geometry2: WKT string of the reference geometry. tolerance: Distance tolerance for snapping. Returns: Dictionary with status, message, and snapped geometry as WKT. """ try: from shapely import wkt from shapely.ops import snap geom1 = wkt.loads(geometry1) geom2 = wkt.loads(geometry2) snapped = snap(geom1, geom2, tolerance) return { "status": "success", "geometry": snapped.wkt, "message": "Geometry snapped successfully" } except Exception as e: logger.error(f"Error in snap_geometry: {str(e)}") return {"status": "error", "message": str(e)}
  • The @gis_mcp.tool() decorator that registers the snap_geometry function as an MCP tool.
    @gis_mcp.tool()
  • Function signature and docstring defining the input schema (geometry1: str WKT, geometry2: str WKT, tolerance: float) and output format.
    def snap_geometry(geometry1: str, geometry2: str, tolerance: float) -> Dict[str, Any]: """ Snap one geometry to another using shapely.ops.snap. Args: geometry1: WKT string of the geometry to be snapped. geometry2: WKT string of the reference geometry. tolerance: Distance tolerance for snapping. Returns: Dictionary with status, message, and snapped geometry as WKT. """
  • Listing of 'snap_geometry' in the shapely_util operations resource for discovery.
    "snap_geometry",

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mahdin75/gis-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server