Commit cfaf93d
committed
Add WKT/PROJ CRS support via pyproj
CRS can now be specified as WKT strings, PROJ strings, or EPSG
integers. pyproj (lazy import) resolves between them:
Read side:
- crs_wkt attr is populated by resolving EPSG -> WKT via pyproj
- Falls back gracefully if pyproj is not installed (EPSG still works)
Write side:
- crs= parameter on write_geotiff accepts int (EPSG), WKT string,
or PROJ string. String inputs are resolved to EPSG via
pyproj.CRS.from_user_input().to_epsg().
- DataArray with crs_wkt attr (no integer crs) is also handled:
the WKT is resolved to EPSG for the GeoKeyDirectory.
This means files with user-defined CRS no longer lose their spatial
reference when round-tripped, as long as pyproj can resolve the
WKT/PROJ string to an EPSG code.
5 new tests: WKT from EPSG, write with WKT string, write with PROJ
string, crs_wkt attr round-trip, and no-CRS baseline.1 parent 6601bcf commit cfaf93d
File tree
3 files changed
+125
-5
lines changed- xrspatial/geotiff
- tests
3 files changed
+125
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
26 | 40 | | |
27 | 41 | | |
28 | 42 | | |
| |||
132 | 146 | | |
133 | 147 | | |
134 | 148 | | |
| 149 | + | |
| 150 | + | |
135 | 151 | | |
136 | 152 | | |
137 | 153 | | |
| |||
214 | 230 | | |
215 | 231 | | |
216 | 232 | | |
217 | | - | |
| 233 | + | |
218 | 234 | | |
219 | 235 | | |
220 | 236 | | |
| |||
231 | 247 | | |
232 | 248 | | |
233 | 249 | | |
234 | | - | |
235 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
236 | 254 | | |
237 | 255 | | |
238 | 256 | | |
| |||
252 | 270 | | |
253 | 271 | | |
254 | 272 | | |
255 | | - | |
| 273 | + | |
256 | 274 | | |
257 | 275 | | |
258 | 276 | | |
259 | 277 | | |
260 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
261 | 285 | | |
262 | 286 | | |
263 | 287 | | |
264 | 288 | | |
265 | | - | |
| 289 | + | |
266 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
267 | 296 | | |
268 | 297 | | |
269 | 298 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
110 | 112 | | |
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
114 | 128 | | |
115 | 129 | | |
116 | 130 | | |
| |||
385 | 399 | | |
386 | 400 | | |
387 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
388 | 407 | | |
389 | 408 | | |
390 | 409 | | |
| |||
410 | 429 | | |
411 | 430 | | |
412 | 431 | | |
| 432 | + | |
413 | 433 | | |
414 | 434 | | |
415 | 435 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
340 | 411 | | |
341 | 412 | | |
342 | 413 | | |
| |||
0 commit comments