$npx -y skills add opengeos/geoai-skills --skill inspect-geoInspect any raster or vector geospatial file. Returns CRS, bounds, bands, resolution, dtype, attribute summaries, and band statistics. Supports GeoTIFF, Shapefile, GeoJSON, GeoPackage, GeoParquet, and more.
| 1 | You are helping the user inspect a geospatial data file. |
| 2 | |
| 3 | Filename given: `$0` |
| 4 | Question: `${1:-describe the data}` |
| 5 | |
| 6 | Follow these steps in order, stopping and reporting clearly if any step fails. |
| 7 | |
| 8 | ## Step 1 -- Resolve the file path |
| 9 | |
| 10 | If `$0` looks like an absolute path, use it directly. Otherwise search for it: |
| 11 | |
| 12 | ```bash |
| 13 | find "$PWD" -name "$0" -not -path '*/.git/*' 2>/dev/null |
| 14 | ``` |
| 15 | |
| 16 | - **Zero results** -> tell the user the file was not found and stop. |
| 17 | - **More than one result** -> list all matches, ask the user to re-run with a fuller path, and stop. |
| 18 | - **Exactly one result** -> use that full path as `RESOLVED_PATH`. |
| 19 | |
| 20 | ## Step 2 -- Classify the file type |
| 21 | |
| 22 | Determine whether the file is raster or vector based on its extension: |
| 23 | |
| 24 | - **Raster**: `.tif`, `.tiff`, `.img`, `.jp2`, `.vrt`, `.nc`, `.hdf` |
| 25 | - **Vector**: `.geojson`, `.json`, `.shp`, `.gpkg`, `.parquet`, `.geoparquet`, `.fgb`, `.kml` |
| 26 | |
| 27 | If the extension is ambiguous, try raster first, then vector. |
| 28 | |
| 29 | ## Step 3 -- Run the appropriate inspection |
| 30 | |
| 31 | ### Raster files |
| 32 | |
| 33 | ```bash |
| 34 | python3 -c " |
| 35 | import geoai |
| 36 | |
| 37 | info = geoai.get_raster_info('RESOLVED_PATH') |
| 38 | for k, v in info.items(): |
| 39 | print(f'{k}: {v}') |
| 40 | |
| 41 | print('---') |
| 42 | print('Band Statistics:') |
| 43 | stats = geoai.get_raster_stats('RESOLVED_PATH') |
| 44 | for k, v in stats.items(): |
| 45 | print(f'{k}: {v}') |
| 46 | " |
| 47 | ``` |
| 48 | |
| 49 | ### Vector files |
| 50 | |
| 51 | ```bash |
| 52 | python3 -c " |
| 53 | import geoai |
| 54 | |
| 55 | info = geoai.get_vector_info('RESOLVED_PATH') |
| 56 | for k, v in info.items(): |
| 57 | print(f'{k}: {v}') |
| 58 | " |
| 59 | ``` |
| 60 | |
| 61 | Replace `RESOLVED_PATH` with the actual absolute path before running. |
| 62 | |
| 63 | ## Step 4 -- Answer the user's question |
| 64 | |
| 65 | Using the metadata retrieved in Step 3, answer: |
| 66 | |
| 67 | `${1:-describe the data: summarize the file type, CRS, extent, and any notable properties.}` |
| 68 | |
| 69 | For vector files, if the question references a specific attribute, run an additional analysis: |
| 70 | |
| 71 | ```bash |
| 72 | python3 -c " |
| 73 | import geoai |
| 74 | result = geoai.analyze_vector_attributes('RESOLVED_PATH') |
| 75 | print(result) |
| 76 | " |
| 77 | ``` |
| 78 | |
| 79 | ## Step 5 -- Update state |
| 80 | |
| 81 | Resolve the state directory: |
| 82 | |
| 83 | ```bash |
| 84 | STATE_DIR="" |
| 85 | test -f .geoai-skills/state.json && STATE_DIR=".geoai-skills" |
| 86 | PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")" |
| 87 | PROJECT_ID="$(echo "$PROJECT_ROOT" | tr '/' '-')" |
| 88 | test -f "$HOME/.geoai-skills/$PROJECT_ID/state.json" && STATE_DIR="$HOME/.geoai-skills/$PROJECT_ID" |
| 89 | ``` |
| 90 | |
| 91 | If `STATE_DIR` is set, update it with the inspected file info: |
| 92 | |
| 93 | ```bash |
| 94 | python3 -c " |
| 95 | import json, os |
| 96 | state_file = 'STATE_DIR/state.json' |
| 97 | state = {} |
| 98 | if os.path.exists(state_file): |
| 99 | with open(state_file) as f: |
| 100 | state = json.load(f) |
| 101 | state['last_inspected'] = { |
| 102 | 'path': 'RESOLVED_PATH', |
| 103 | 'type': 'TYPE', |
| 104 | } |
| 105 | with open(state_file, 'w') as f: |
| 106 | json.dump(state, f, indent=2) |
| 107 | " |
| 108 | ``` |
| 109 | |
| 110 | Replace `STATE_DIR`, `RESOLVED_PATH`, and `TYPE` (raster or vector) with actual values. |
| 111 | |
| 112 | If no state directory exists yet, skip this step silently. |
| 113 | |
| 114 | ## Step 6 -- Suggest next steps |
| 115 | |
| 116 | After reporting, briefly mention: |
| 117 | |
| 118 | - For raster files: *"To process this raster (clip, mosaic, stack bands), use `/geoai-skills:process-raster`. To run AI detection on it, use `/geoai-skills:detect-objects`."* |
| 119 | - For vector files: *"To download more vector data for this area, use `/geoai-skills:overture-data`."* |
| 120 | |
| 121 | Keep suggestions brief and show them only once. |
| 122 | |
| 123 | ## Error handling |
| 124 | |
| 125 | - If `python3` is not found or `import geoai` fails, delegate to `/geoai-skills:install-geoai`. |
| 126 | - If rasterio or geopandas fails to read the file, try the GDAL/OGR fallback: |
| 127 | |
| 128 | ```bash |
| 129 | python3 -c " |
| 130 | import geoai |
| 131 | info = geoai.get_raster_info_gdal('RESOLVED_PATH') |
| 132 | for k, v in info.items(): |
| 133 | print(f'{k}: {v}') |
| 134 | " |
| 135 | ``` |
| 136 | |
| 137 | Or for vectors: |
| 138 | |
| 139 | ```bash |
| 140 | python3 -c " |
| 141 | import geoai |
| 142 | info = geoai.get_vector_info_ogr('RESOLVED_PATH') |
| 143 | for k, v in info.items(): |
| 144 | print(f'{k}: {v}') |
| 145 | " |
| 146 | ``` |