ign_get_rpg
Query agricultural parcel data from France's Registre Parcellaire Graphique (RPG) for land use analysis, crop identification, and CAP subsidy verification by providing location and year parameters.
Instructions
Query the Registre Parcellaire Graphique (RPG) for agricultural parcel information.
The RPG contains agricultural land use data declared by farmers for CAP (Common Agricultural Policy) subsidies.
Two versions exist:
V1 (2010-2014): Anonymous farm blocks (îlots)
V2 (2015+): Graphic parcels with crop information
Args:
annee (number): Year of data (2010-2024)
geom (string): GeoJSON geometry (required)
code_cultu (string, optional): Crop culture code filter
_limit (number): Max results
_start (number): Pagination offset
Returns: GeoJSON FeatureCollection with:
V1: num_ilot, commune, surf_decla, code_cultu, nom_cultu
V2: id_parcel, surf_parc, code_cultu, code_group, culture_d1, culture_d2
Examples:
"Find crops at this location in 2023" -> annee=2023, geom={"type":"Point",...}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| annee | Yes | Year (2010-2024) | |
| geom | Yes | GeoJSON geometry (required) | |
| code_cultu | No | Crop culture code | |
| _limit | No | Maximum number of results (1-1000) | |
| _start | No | Starting position for pagination | |
| response_format | No | Output format: 'markdown' for human-readable or 'json' for machine-readable | markdown |
Implementation Reference
- src/index.ts:294-316 (handler)The asynchronous handler function implementing the core logic of the 'ign_get_rpg' tool. It destructures parameters, determines the RPG version (v1 or v2) based on the year, makes an API request to the corresponding endpoint, and returns either raw JSON or formatted markdown GeoJSON response.async (params) => { const { annee, response_format, ...queryParams } = params; const version = annee <= 2014 ? "v1" : "v2"; const endpoint = `/rpg/${version}`; const data = await apiRequest<unknown>(endpoint, { params: { annee, ...queryParams } as Record<string, string | number | boolean | undefined>, }); if (response_format === ResponseFormat.JSON) { return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } const markdown = formatGeoJSONToMarkdown( data as import("./types.js").GeoJSONFeatureCollection, `Parcelles agricoles RPG ${annee}` ); return { content: [{ type: "text", text: truncateResponse(markdown, CHARACTER_LIMIT) }], }; }
- src/index.ts:275-286 (schema)Zod input validation schema for the 'ign_get_rpg' tool, defining required 'annee' (2010-2024), 'geom' (GeoJSON), optional 'code_cultu', pagination parameters, and response format.inputSchema: z.object({ annee: z .number() .int() .min(2010) .max(2024) .describe("Year (2010-2024)"), geom: GeometrySchema.describe("GeoJSON geometry (required)"), code_cultu: z.string().optional().describe("Crop culture code"), ...PaginationSchema, response_format: ResponseFormatSchema, }).strict(),
- src/index.ts:249-317 (registration)Registration of the 'ign_get_rpg' tool using server.registerTool, including the tool name, metadata (title, description), input schema, annotations, and the handler function.server.registerTool( "ign_get_rpg", { title: "Get agricultural parcels (RPG)", description: `Query the Registre Parcellaire Graphique (RPG) for agricultural parcel information. The RPG contains agricultural land use data declared by farmers for CAP (Common Agricultural Policy) subsidies. Two versions exist: - V1 (2010-2014): Anonymous farm blocks (îlots) - V2 (2015+): Graphic parcels with crop information Args: - annee (number): Year of data (2010-2024) - geom (string): GeoJSON geometry (required) - code_cultu (string, optional): Crop culture code filter - _limit (number): Max results - _start (number): Pagination offset Returns: GeoJSON FeatureCollection with: - V1: num_ilot, commune, surf_decla, code_cultu, nom_cultu - V2: id_parcel, surf_parc, code_cultu, code_group, culture_d1, culture_d2 Examples: - "Find crops at this location in 2023" -> annee=2023, geom={"type":"Point",...}`, inputSchema: z.object({ annee: z .number() .int() .min(2010) .max(2024) .describe("Year (2010-2024)"), geom: GeometrySchema.describe("GeoJSON geometry (required)"), code_cultu: z.string().optional().describe("Crop culture code"), ...PaginationSchema, response_format: ResponseFormatSchema, }).strict(), annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, }, async (params) => { const { annee, response_format, ...queryParams } = params; const version = annee <= 2014 ? "v1" : "v2"; const endpoint = `/rpg/${version}`; const data = await apiRequest<unknown>(endpoint, { params: { annee, ...queryParams } as Record<string, string | number | boolean | undefined>, }); if (response_format === ResponseFormat.JSON) { return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } const markdown = formatGeoJSONToMarkdown( data as import("./types.js").GeoJSONFeatureCollection, `Parcelles agricoles RPG ${annee}` ); return { content: [{ type: "text", text: truncateResponse(markdown, CHARACTER_LIMIT) }], }; } );