scale_geometry
Scale geometric shapes by adjusting X and Y dimensions to resize maps, models, or spatial data for analysis and visualization.
Instructions
Scale a geometry.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes | ||
| xfact | Yes | ||
| yfact | Yes | ||
| origin | No | center |
Implementation Reference
- src/gis_mcp/shapely_functions.py:317-334 (handler)The main execution logic for the 'scale_geometry' tool. Parses WKT input, applies shapely.affinity.scale with xfact, yfact, and origin parameters, returns scaled geometry as WKT.@gis_mcp.tool() def scale_geometry(geometry: str, xfact: float, yfact: float, origin: str = "center") -> Dict[str, Any]: """Scale a geometry.""" try: from shapely import wkt from shapely.affinity import scale geom = wkt.loads(geometry) result = scale(geom, xfact=xfact, yfact=yfact, origin=origin) return { "status": "success", "geometry": result.wkt, "message": "Geometry scaled successfully" } except Exception as e: logger.error(f"Error scaling geometry: {str(e)}") raise ValueError(f"Failed to scale geometry: {str(e)}")
- src/gis_mcp/shapely_functions.py:39-48 (registration)Resource endpoint listing available transformation tools, including 'scale_geometry'.@gis_mcp.resource("gis://operations/transformations") def get_transformations() -> Dict[str, List[str]]: """List available geometric transformations.""" return { "operations": [ "rotate_geometry", "scale_geometry", "translate_geometry" ] }
- Function signature defining input schema (geometry: str WKT, xfact/yfact: float scaling factors, origin: str='center') and output (Dict with status, geometry WKT, message).def scale_geometry(geometry: str, xfact: float, yfact: float, origin: str = "center") -> Dict[str, Any]: