pyogrio 0.9.0__cp39-cp39-macosx_12_0_arm64.whl → 0.11.0__cp39-cp39-macosx_12_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyogrio might be problematic. Click here for more details.

Files changed (86) hide show
  1. pyogrio/.dylibs/{libgdal.34.3.8.5.dylib → libgdal.36.3.10.3.dylib} +0 -0
  2. pyogrio/__init__.py +28 -21
  3. pyogrio/_compat.py +15 -1
  4. pyogrio/_env.py +4 -6
  5. pyogrio/_err.cpython-39-darwin.so +0 -0
  6. pyogrio/_geometry.cpython-39-darwin.so +0 -0
  7. pyogrio/_io.cpython-39-darwin.so +0 -0
  8. pyogrio/_ogr.cpython-39-darwin.so +0 -0
  9. pyogrio/_version.py +3 -3
  10. pyogrio/_vsi.cpython-39-darwin.so +0 -0
  11. pyogrio/core.py +86 -20
  12. pyogrio/errors.py +9 -16
  13. pyogrio/gdal_data/GDAL-targets-release.cmake +3 -3
  14. pyogrio/gdal_data/GDAL-targets.cmake +2 -2
  15. pyogrio/gdal_data/GDALConfig.cmake +0 -1
  16. pyogrio/gdal_data/GDALConfigVersion.cmake +3 -3
  17. pyogrio/gdal_data/MM_m_idofic.csv +321 -0
  18. pyogrio/gdal_data/gdalinfo_output.schema.json +3 -3
  19. pyogrio/gdal_data/gdaltileindex.xsd +253 -0
  20. pyogrio/gdal_data/gdalvrt.xsd +178 -63
  21. pyogrio/gdal_data/nitf_spec.xml +1 -17
  22. pyogrio/gdal_data/nitf_spec.xsd +1 -17
  23. pyogrio/gdal_data/ogrinfo_output.schema.json +23 -0
  24. pyogrio/gdal_data/ogrvrt.xsd +4 -17
  25. pyogrio/gdal_data/osmconf.ini +3 -1
  26. pyogrio/gdal_data/pci_datum.txt +222 -155
  27. pyogrio/gdal_data/pci_ellips.txt +90 -38
  28. pyogrio/gdal_data/pdfcomposition.xsd +1 -17
  29. pyogrio/gdal_data/vcpkg.spdx.json +29 -24
  30. pyogrio/gdal_data/vcpkg_abi_info.txt +31 -30
  31. pyogrio/gdal_data/vdv452.xml +1 -17
  32. pyogrio/gdal_data/vdv452.xsd +1 -17
  33. pyogrio/geopandas.py +122 -66
  34. pyogrio/proj_data/ITRF2014 +1 -1
  35. pyogrio/proj_data/ITRF2020 +91 -0
  36. pyogrio/proj_data/proj-config-version.cmake +2 -2
  37. pyogrio/proj_data/proj-config.cmake +1 -1
  38. pyogrio/proj_data/proj-targets.cmake +3 -3
  39. pyogrio/proj_data/proj.db +0 -0
  40. pyogrio/proj_data/proj.ini +11 -3
  41. pyogrio/proj_data/proj4-targets.cmake +3 -3
  42. pyogrio/proj_data/projjson.schema.json +1 -1
  43. pyogrio/proj_data/usage +7 -2
  44. pyogrio/proj_data/vcpkg.spdx.json +27 -22
  45. pyogrio/proj_data/vcpkg_abi_info.txt +18 -17
  46. pyogrio/raw.py +46 -30
  47. pyogrio/tests/conftest.py +214 -12
  48. pyogrio/tests/fixtures/README.md +32 -13
  49. pyogrio/tests/fixtures/curve.gpkg +0 -0
  50. pyogrio/tests/fixtures/{test_multisurface.gpkg → curvepolygon.gpkg} +0 -0
  51. pyogrio/tests/fixtures/line_zm.gpkg +0 -0
  52. pyogrio/tests/fixtures/multisurface.gpkg +0 -0
  53. pyogrio/tests/test_arrow.py +181 -24
  54. pyogrio/tests/test_core.py +170 -76
  55. pyogrio/tests/test_geopandas_io.py +483 -135
  56. pyogrio/tests/test_path.py +39 -17
  57. pyogrio/tests/test_raw_io.py +170 -55
  58. pyogrio/tests/test_util.py +56 -0
  59. pyogrio/util.py +69 -32
  60. pyogrio-0.11.0.dist-info/METADATA +124 -0
  61. {pyogrio-0.9.0.dist-info → pyogrio-0.11.0.dist-info}/RECORD +64 -78
  62. {pyogrio-0.9.0.dist-info → pyogrio-0.11.0.dist-info}/WHEEL +2 -1
  63. {pyogrio-0.9.0.dist-info → pyogrio-0.11.0.dist-info/licenses}/LICENSE +1 -1
  64. pyogrio/_err.pxd +0 -4
  65. pyogrio/_err.pyx +0 -250
  66. pyogrio/_geometry.pxd +0 -4
  67. pyogrio/_geometry.pyx +0 -129
  68. pyogrio/_io.pxd +0 -0
  69. pyogrio/_io.pyx +0 -2742
  70. pyogrio/_ogr.pxd +0 -444
  71. pyogrio/_ogr.pyx +0 -346
  72. pyogrio/_vsi.pxd +0 -4
  73. pyogrio/_vsi.pyx +0 -140
  74. pyogrio/arrow_bridge.h +0 -115
  75. pyogrio/gdal_data/bag_template.xml +0 -201
  76. pyogrio/gdal_data/gmlasconf.xml +0 -169
  77. pyogrio/gdal_data/gmlasconf.xsd +0 -1066
  78. pyogrio/gdal_data/netcdf_config.xsd +0 -143
  79. pyogrio/tests/fixtures/poly_not_enough_points.shp.zip +0 -0
  80. pyogrio/tests/fixtures/test_datetime.geojson +0 -7
  81. pyogrio/tests/fixtures/test_datetime_tz.geojson +0 -8
  82. pyogrio/tests/fixtures/test_fgdb.gdb.zip +0 -0
  83. pyogrio/tests/fixtures/test_nested.geojson +0 -18
  84. pyogrio/tests/fixtures/test_ogr_types_list.geojson +0 -12
  85. pyogrio-0.9.0.dist-info/METADATA +0 -100
  86. {pyogrio-0.9.0.dist-info → pyogrio-0.11.0.dist-info}/top_level.txt +0 -0
@@ -3,13 +3,13 @@
3
3
  "spdxVersion": "SPDX-2.2",
4
4
  "dataLicense": "CC0-1.0",
5
5
  "SPDXID": "SPDXRef-DOCUMENT",
6
- "documentNamespace": "https://spdx.org/spdxdocs/proj-arm64-osx-dynamic-release-9.4.0-ec398e5d-1049-4f2d-9822-3a705d082dc0",
7
- "name": "proj:arm64-osx-dynamic-release@9.4.0 da6388a3ef86d20dc670914122fe4a63d2fe8c66fdbffae2d8ceb037931218a5",
6
+ "documentNamespace": "https://spdx.org/spdxdocs/proj-arm64-osx-dynamic-release-9.6.0-07767e49-9fc1-4d61-8f9d-90ab0d96ed0c",
7
+ "name": "proj:arm64-osx-dynamic-release@9.6.0 b2ef1758b546a7589c0740f68647dbe45409b00c48c51a3aaa5084952d1e3ee1",
8
8
  "creationInfo": {
9
9
  "creators": [
10
- "Tool: vcpkg-d6945642ee5c3076addd1a42c331bbf4cfc97457"
10
+ "Tool: vcpkg-2025-04-16-f9b6c6917b23c1ccf16c1a9f015ebabf8f615045"
11
11
  ],
12
- "created": "2024-06-10T17:01:57Z"
12
+ "created": "2025-05-07T14:21:43Z"
13
13
  },
14
14
  "relationships": [
15
15
  {
@@ -72,6 +72,11 @@
72
72
  "relationshipType": "CONTAINED_BY",
73
73
  "relatedSpdxElement": "SPDXRef-port"
74
74
  },
75
+ {
76
+ "spdxElementId": "SPDXRef-file-3",
77
+ "relationshipType": "DEPENDENCY_MANIFEST_OF",
78
+ "relatedSpdxElement": "SPDXRef-port"
79
+ },
75
80
  {
76
81
  "spdxElementId": "SPDXRef-file-4",
77
82
  "relationshipType": "CONTAINED_BY",
@@ -87,8 +92,8 @@
87
92
  {
88
93
  "name": "proj",
89
94
  "SPDXID": "SPDXRef-port",
90
- "versionInfo": "9.4.0",
91
- "downloadLocation": "git+https://github.com/Microsoft/vcpkg@62e9ace469641b907291184ebc7e76d96f629881",
95
+ "versionInfo": "9.6.0",
96
+ "downloadLocation": "git+https://github.com/Microsoft/vcpkg@157177ebd5778822eaf744dd5c725e553758a866",
92
97
  "homepage": "https://proj.org/",
93
98
  "licenseConcluded": "MIT",
94
99
  "licenseDeclared": "NOASSERTION",
@@ -99,7 +104,7 @@
99
104
  {
100
105
  "name": "proj:arm64-osx-dynamic-release",
101
106
  "SPDXID": "SPDXRef-binary",
102
- "versionInfo": "da6388a3ef86d20dc670914122fe4a63d2fe8c66fdbffae2d8ceb037931218a5",
107
+ "versionInfo": "b2ef1758b546a7589c0740f68647dbe45409b00c48c51a3aaa5084952d1e3ee1",
103
108
  "downloadLocation": "NONE",
104
109
  "licenseConcluded": "MIT",
105
110
  "licenseDeclared": "NOASSERTION",
@@ -107,88 +112,88 @@
107
112
  "comment": "This is a binary package built by vcpkg."
108
113
  },
109
114
  {
110
- "SPDXID": "SPDXRef-resource-1",
115
+ "SPDXID": "SPDXRef-resource-0",
111
116
  "name": "OSGeo/PROJ",
112
- "downloadLocation": "git+https://github.com/OSGeo/PROJ@9.4.0",
117
+ "downloadLocation": "git+https://github.com/OSGeo/PROJ@9.6.0",
113
118
  "licenseConcluded": "NOASSERTION",
114
119
  "licenseDeclared": "NOASSERTION",
115
120
  "copyrightText": "NOASSERTION",
116
121
  "checksums": [
117
122
  {
118
123
  "algorithm": "SHA512",
119
- "checksumValue": "5bc53723a81d9950599d6c47a837de5e9052aa56f943951e3ad0911cbeb71585bac648f37b9b626f32bb5d0b481ce5aef9be0833910e53b4b015b573808b8981"
124
+ "checksumValue": "45d8bfb883431c62c2627cecf583a4374efda7f109c2b43d3fe8ef18136f30cf57682d6e6c44256ba099533754392c87f71e940a41018a577f540310001e0f05"
120
125
  }
121
126
  ]
122
127
  }
123
128
  ],
124
129
  "files": [
125
130
  {
126
- "fileName": ".//usr/local/share/vcpkg/buildtrees/versioning_/versions/proj/62e9ace469641b907291184ebc7e76d96f629881/usage",
131
+ "fileName": "./sqlite.diff",
127
132
  "SPDXID": "SPDXRef-file-0",
128
133
  "checksums": [
129
134
  {
130
135
  "algorithm": "SHA256",
131
- "checksumValue": "26169363c27e71a44cba9d703b22bbd13c191ab5e2d0612b3dd35c735c971fe6"
136
+ "checksumValue": "75049bf707593bb9a22a6f77ccc062fe1343484a12920adc7be5c29c14746857"
132
137
  }
133
138
  ],
134
139
  "licenseConcluded": "NOASSERTION",
135
140
  "copyrightText": "NOASSERTION"
136
141
  },
137
142
  {
138
- "fileName": ".//usr/local/share/vcpkg/buildtrees/versioning_/versions/proj/62e9ace469641b907291184ebc7e76d96f629881/portfile.cmake",
143
+ "fileName": "./usage",
139
144
  "SPDXID": "SPDXRef-file-1",
140
145
  "checksums": [
141
146
  {
142
147
  "algorithm": "SHA256",
143
- "checksumValue": "58b4048cfc81891c1e32e41bc00b52ea7ae2821bd577b46ab63d2c962ef8747d"
148
+ "checksumValue": "ae06beae83376cd9f11db8c2596bd038f89ae1e2cd32b82ee333f1572070370a"
144
149
  }
145
150
  ],
146
151
  "licenseConcluded": "NOASSERTION",
147
152
  "copyrightText": "NOASSERTION"
148
153
  },
149
154
  {
150
- "fileName": ".//usr/local/share/vcpkg/buildtrees/versioning_/versions/proj/62e9ace469641b907291184ebc7e76d96f629881/vcpkg.json",
155
+ "fileName": "./portfile.cmake",
151
156
  "SPDXID": "SPDXRef-file-2",
152
157
  "checksums": [
153
158
  {
154
159
  "algorithm": "SHA256",
155
- "checksumValue": "d31d1d3beb5ef0890e4b5db1ee5b72a925a58aa53bfaee688d4b5af1cea2bba4"
160
+ "checksumValue": "5fd54e02ca8ceda95178cb097182d81c5e10590cb15f74c1f67ed328eab84af2"
156
161
  }
157
162
  ],
158
163
  "licenseConcluded": "NOASSERTION",
159
164
  "copyrightText": "NOASSERTION"
160
165
  },
161
166
  {
162
- "fileName": ".//usr/local/share/vcpkg/buildtrees/versioning_/versions/proj/62e9ace469641b907291184ebc7e76d96f629881/remove_toolset_restriction.patch",
167
+ "fileName": "./vcpkg.json",
163
168
  "SPDXID": "SPDXRef-file-3",
164
169
  "checksums": [
165
170
  {
166
171
  "algorithm": "SHA256",
167
- "checksumValue": "25c1c986673bd539f5ec920684a08b38d0d37d9e24b6793e5b79dbd717bde04e"
172
+ "checksumValue": "88ecc073bf74d5a0a114bb1357499f6210c84a4f5a8b7beed2af94907f2f8802"
168
173
  }
169
174
  ],
170
175
  "licenseConcluded": "NOASSERTION",
171
176
  "copyrightText": "NOASSERTION"
172
177
  },
173
178
  {
174
- "fileName": ".//usr/local/share/vcpkg/buildtrees/versioning_/versions/proj/62e9ace469641b907291184ebc7e76d96f629881/fix-proj4-targets-cmake.patch",
179
+ "fileName": "./remove_toolset_restriction.patch",
175
180
  "SPDXID": "SPDXRef-file-4",
176
181
  "checksums": [
177
182
  {
178
183
  "algorithm": "SHA256",
179
- "checksumValue": "d76e1d419d3367dda3381fd11a637f3465bc838d611fa8ceaca20048c1b3cd6e"
184
+ "checksumValue": "25c1c986673bd539f5ec920684a08b38d0d37d9e24b6793e5b79dbd717bde04e"
180
185
  }
181
186
  ],
182
187
  "licenseConcluded": "NOASSERTION",
183
188
  "copyrightText": "NOASSERTION"
184
189
  },
185
190
  {
186
- "fileName": ".//usr/local/share/vcpkg/buildtrees/versioning_/versions/proj/62e9ace469641b907291184ebc7e76d96f629881/fix-win-output-name.patch",
191
+ "fileName": "./fix-proj4-targets-cmake.patch",
187
192
  "SPDXID": "SPDXRef-file-5",
188
193
  "checksums": [
189
194
  {
190
195
  "algorithm": "SHA256",
191
- "checksumValue": "706e536cfe9a90c1b071ab5b00932fa96bb35c67fcb0f96c0fc4feb7c0b44011"
196
+ "checksumValue": "d76e1d419d3367dda3381fd11a637f3465bc838d611fa8ceaca20048c1b3cd6e"
192
197
  }
193
198
  ],
194
199
  "licenseConcluded": "NOASSERTION",
@@ -1,27 +1,28 @@
1
- cmake 3.29.3
2
- curl 2add7a3b448fe6b0bf867a8354c0f1fa79e6049a11d1053f698a66a965f77ff4
1
+ cmake 3.31.6
2
+ curl 22b161e12401607707f5d3e4c3e05b8befaa7594450e9cee73d5bf486255799d
3
3
  features core;net;tiff
4
4
  fix-proj4-targets-cmake.patch d76e1d419d3367dda3381fd11a637f3465bc838d611fa8ceaca20048c1b3cd6e
5
- fix-win-output-name.patch 706e536cfe9a90c1b071ab5b00932fa96bb35c67fcb0f96c0fc4feb7c0b44011
6
- nlohmann-json 16ccf1d0a002391d731f28e3c61b302ef43ad42cc0fab50d09da068056512578
7
- portfile.cmake 58b4048cfc81891c1e32e41bc00b52ea7ae2821bd577b46ab63d2c962ef8747d
8
- ports.cmake 0500e9e2422fe0084c99bdd0c9de4c7069b76da14c8b58228a7e95ebac43058a
5
+ nlohmann-json 1e32e49c1e3c56c62d33e8b996ace94c52cfb74937b57148f0347bcda5ccc07f
6
+ portfile.cmake 5fd54e02ca8ceda95178cb097182d81c5e10590cb15f74c1f67ed328eab84af2
7
+ ports.cmake a9f8f745f9f4d225039f9810e79670f10f38c7455222865616ce430a06f75d1f
9
8
  post_build_checks 2
10
9
  remove_toolset_restriction.patch 25c1c986673bd539f5ec920684a08b38d0d37d9e24b6793e5b79dbd717bde04e
11
- sqlite3 2f9ad09fd24b6b39217bc2fe3e4a7c7dacb02c8beaaac7d314b1335e579bb0d5
12
- sqlite3 664423578924aaba4beb2e4b03b82cbbc78e485f20ceef23ff0b19c5bf16a7ae
13
- tiff 555062d07bdd54cfcc1d09a94185719b6c434e092290b72378006f266192752b
10
+ sqlite.diff 75049bf707593bb9a22a6f77ccc062fe1343484a12920adc7be5c29c14746857
11
+ sqlite3 4c05171c755f22ec24b32b862029448485cd9718ab920d3b245c141d5f43696a
12
+ sqlite3 64dc4f879d155bad048c2f3eebbf22674164c996decdf661fcfcd75cda1a970f
13
+ tiff fd68529926bf04dedbf138cf60eaf8c8e73af7bebcb3341657678f3e5ceddedb
14
14
  triplet arm64-osx-dynamic-release
15
- triplet_abi bfb2f1a725a6c7d4c5a71c9867dbce26242b53ad1005a453f934440a490c77ba-a654e5c1a635cb784f3168426c422995eefe31912588726942497566a5bca495-5f75c9acc02e05029cedb7eca90c49644cc3a77a
16
- usage 26169363c27e71a44cba9d703b22bbd13c191ab5e2d0612b3dd35c735c971fe6
17
- vcpkg-cmake 0a26d48713a5847cab34bf40b6f6e0534b98af1b9ee4fc1c0397d96f3bf33f9c
18
- vcpkg-cmake-config 934e27de6b7820c88fbb9c24cf9de8cd035862096fa9214a969638a5f1236364
19
- vcpkg.json d31d1d3beb5ef0890e4b5db1ee5b72a925a58aa53bfaee688d4b5af1cea2bba4
15
+ triplet_abi bfb2f1a725a6c7d4c5a71c9867dbce26242b53ad1005a453f934440a490c77ba-c6536c929f0b7e5191e31cc452a71864a2b2273ecad8b5d2b27a82f75d8cc6af-ff2c5a09a0ce40d6d8029ce6365bdc326e54075b
16
+ usage ae06beae83376cd9f11db8c2596bd038f89ae1e2cd32b82ee333f1572070370a
17
+ vcpkg-cmake 40a914f9f2ce407f0c6effd8372fdaf561b2d183abbde65dc9ead58fe558cf9a
18
+ vcpkg-cmake-config d2c96fec92e0c3a0078788407dd660b8ad7f4bc34e553c17b04dd5f1d2b57ca7
19
+ vcpkg.json 88ecc073bf74d5a0a114bb1357499f6210c84a4f5a8b7beed2af94907f2f8802
20
20
  vcpkg_check_features 943b217e0968d64cf2cb9c272608e6a0b497377e792034f819809a79e1502c2b
21
- vcpkg_copy_pdbs d57e4f196c82dc562a9968c6155073094513c31e2de475694143d3aa47954b1c
21
+ vcpkg_copy_pdbs d15c2f2822d93ecb9023af44803328e491c5374136e0813600289582a72d196d
22
22
  vcpkg_copy_tools 3d45ff761bddbabe8923b52330168dc3abd295fa469d3f2e47cb14dce85332d5
23
- vcpkg_fixup_pkgconfig 904e67c46ecbb67379911bc1d7222855c0cbfcf1129bf47783858bcf0cc44970
23
+ vcpkg_fixup_pkgconfig 1a15f6c6d8e2b244d83a7514a0412d339127d2217d1df60ad1388b546c85f777
24
24
  vcpkg_from_git 96ed81968f76354c00096dd8cd4e63c6a235fa969334a11ab18d11c0c512ff58
25
25
  vcpkg_from_github b743742296a114ea1b18ae99672e02f142c4eb2bef7f57d36c038bedbfb0502f
26
+ vcpkg_install_copyright ba6c169ab4e59fa05682e530cdeb883767de22c8391f023d4e6844a7ec5dd3d2
26
27
  vcpkg_list f5de3ebcbc40a4db90622ade9aca918e2cf404dc0d91342fcde457d730e6fa29
27
- vcpkg_replace_string d43c8699ce27e25d47367c970d1c546f6bc36b6df8fb0be0c3986eb5830bd4f1
28
+ vcpkg_replace_string b450deb79207478b37119743e00808ebc42de0628e7b98c14ab24728bd5c78b8
pyogrio/raw.py CHANGED
@@ -1,8 +1,11 @@
1
- from io import BytesIO
1
+ """Low level functions to read and write OGR data sources."""
2
+
2
3
  import warnings
4
+ from io import BytesIO
5
+ from pathlib import Path
3
6
 
4
- from pyogrio._env import GDALEnv
5
7
  from pyogrio._compat import HAS_ARROW_API, HAS_ARROW_WRITE_API, HAS_PYARROW
8
+ from pyogrio._env import GDALEnv
6
9
  from pyogrio.core import detect_write_driver
7
10
  from pyogrio.errors import DataSourceError
8
11
  from pyogrio.util import (
@@ -18,8 +21,8 @@ with GDALEnv():
18
21
  _get_driver_metadata_item,
19
22
  get_gdal_version,
20
23
  get_gdal_version_string,
21
- ogr_driver_supports_write,
22
24
  ogr_driver_supports_vsi,
25
+ ogr_driver_supports_write,
23
26
  )
24
27
 
25
28
 
@@ -61,7 +64,7 @@ def read(
61
64
  Parameters
62
65
  ----------
63
66
  path_or_buffer : pathlib.Path or str, or bytes buffer
64
- A dataset path or URI, or raw buffer.
67
+ A dataset path or URI, raw buffer, or file-like object with a read method.
65
68
  layer : int or str, optional (default: first layer)
66
69
  If an integer is provided, it corresponds to the index of the layer
67
70
  with the data source. If a string is provided, it must match the name
@@ -190,7 +193,6 @@ def read(
190
193
  https://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html
191
194
 
192
195
  """
193
-
194
196
  dataset_kwargs = _preprocess_options_key_value(kwargs) if kwargs else {}
195
197
 
196
198
  return ogr_read(
@@ -233,8 +235,7 @@ def read_arrow(
233
235
  return_fids=False,
234
236
  **kwargs,
235
237
  ):
236
- """
237
- Read OGR data source into a pyarrow Table.
238
+ """Read OGR data source into a pyarrow Table.
238
239
 
239
240
  See docstring of `read` for parameters.
240
241
 
@@ -252,6 +253,7 @@ def read_arrow(
252
253
  "geometry_type": "<geometry_type>",
253
254
  "geometry_name": "<name of geometry column in arrow table>",
254
255
  }
256
+
255
257
  """
256
258
  if not HAS_PYARROW:
257
259
  raise RuntimeError(
@@ -358,8 +360,7 @@ def open_arrow(
358
360
  use_pyarrow=False,
359
361
  **kwargs,
360
362
  ):
361
- """
362
- Open OGR data source as a stream of Arrow record batches.
363
+ """Open OGR data source as a stream of Arrow record batches.
363
364
 
364
365
  See docstring of `read` for parameters.
365
366
 
@@ -388,7 +389,6 @@ def open_arrow(
388
389
 
389
390
  Examples
390
391
  --------
391
-
392
392
  >>> from pyogrio.raw import open_arrow
393
393
  >>> import pyarrow as pa
394
394
  >>> import shapely
@@ -397,8 +397,9 @@ def open_arrow(
397
397
  >>> meta, stream = source
398
398
  >>> # wrap the arrow stream object in a pyarrow RecordBatchReader
399
399
  >>> reader = pa.RecordBatchReader.from_stream(stream)
400
+ >>> geom_col = meta["geometry_name"] or "wkb_geometry"
400
401
  >>> for batch in reader:
401
- >>> geometries = shapely.from_wkb(batch[meta["geometry_name"] or "wkb_geometry"])
402
+ >>> geometries = shapely.from_wkb(batch[geom_col])
402
403
 
403
404
  The returned `stream` object needs to be consumed by a library implementing
404
405
  the Arrow PyCapsule Protocol. In the above example, pyarrow is used through
@@ -407,8 +408,9 @@ def open_arrow(
407
408
 
408
409
  >>> with open_arrow(path, use_pyarrow=True) as source:
409
410
  >>> meta, reader = source
411
+ >>> geom_col = meta["geometry_name"] or "wkb_geometry"
410
412
  >>> for batch in reader:
411
- >>> geometries = shapely.from_wkb(batch[meta["geometry_name"] or "wkb_geometry"])
413
+ >>> geometries = shapely.from_wkb(batch[geom_col])
412
414
 
413
415
  Returns
414
416
  -------
@@ -425,6 +427,7 @@ def open_arrow(
425
427
  "geometry_type": "<geometry_type>",
426
428
  "geometry_name": "<name of geometry column in arrow table>",
427
429
  }
430
+
428
431
  """
429
432
  if not HAS_ARROW_API:
430
433
  raise RuntimeError("GDAL>= 3.6 required to read using arrow")
@@ -454,7 +457,7 @@ def open_arrow(
454
457
 
455
458
 
456
459
  def _parse_options_names(xml):
457
- """Convert metadata xml to list of names"""
460
+ """Convert metadata xml to list of names."""
458
461
  # Based on Fiona's meta.py
459
462
  # (https://github.com/Toblerity/Fiona/blob/91c13ad8424641557a4e5f038f255f9b657b1bc5/fiona/meta.py)
460
463
  import xml.etree.ElementTree as ET
@@ -471,29 +474,27 @@ def _parse_options_names(xml):
471
474
 
472
475
 
473
476
  def _validate_metadata(dataset_metadata, layer_metadata, metadata):
474
- """ """
477
+ """Validate the metadata."""
475
478
  if metadata is not None:
476
479
  if layer_metadata is not None:
477
480
  raise ValueError("Cannot pass both metadata and layer_metadata")
478
481
  layer_metadata = metadata
479
482
 
480
483
  # validate metadata types
481
- for metadata in [dataset_metadata, layer_metadata]:
482
- if metadata is not None:
483
- for k, v in metadata.items():
484
+ for meta in [dataset_metadata, layer_metadata]:
485
+ if meta is not None:
486
+ for k, v in meta.items():
484
487
  if not isinstance(k, str):
485
488
  raise ValueError(f"metadata key {k} must be a string")
486
489
 
487
490
  if not isinstance(v, str):
488
491
  raise ValueError(f"metadata value {v} must be a string")
492
+
489
493
  return dataset_metadata, layer_metadata
490
494
 
491
495
 
492
496
  def _preprocess_options_kwargs(driver, dataset_options, layer_options, kwargs):
493
- """
494
- Preprocess kwargs and split in dataset and layer creation options.
495
- """
496
-
497
+ """Preprocess kwargs and split in dataset and layer creation options."""
497
498
  dataset_kwargs = _preprocess_options_key_value(dataset_options or {})
498
499
  layer_kwargs = _preprocess_options_key_value(layer_options or {})
499
500
  if kwargs:
@@ -516,13 +517,14 @@ def _preprocess_options_kwargs(driver, dataset_options, layer_options, kwargs):
516
517
 
517
518
 
518
519
  def _get_write_path_driver(path, driver, append=False):
519
- """Validate and return path and driver
520
+ """Validate and return path and driver.
520
521
 
521
522
  Parameters
522
523
  ----------
523
524
  path : str or io.BytesIO
524
525
  path to output file on writeable file system or an io.BytesIO object to
525
- allow writing to memory
526
+ allow writing to memory. Will raise NotImplementedError if an open file
527
+ handle is passed.
526
528
  driver : str, optional (default: None)
527
529
  The OGR format driver used to write the vector file. By default attempts
528
530
  to infer driver from path. Must be provided to write to a file-like
@@ -533,8 +535,8 @@ def _get_write_path_driver(path, driver, append=False):
533
535
  Returns
534
536
  -------
535
537
  (path, driver)
536
- """
537
538
 
539
+ """
538
540
  if isinstance(path, BytesIO):
539
541
  if driver is None:
540
542
  raise ValueError("driver must be provided to write to in-memory file")
@@ -554,8 +556,14 @@ def _get_write_path_driver(path, driver, append=False):
554
556
  if append:
555
557
  raise NotImplementedError("append is not supported for in-memory files")
556
558
 
559
+ elif hasattr(path, "write") and not isinstance(path, Path):
560
+ raise NotImplementedError(
561
+ "writing to an open file handle is not yet supported; instead, write to a "
562
+ "BytesIO instance and then read bytes from that to write to the file handle"
563
+ )
564
+
557
565
  else:
558
- path = vsi_path(str(path))
566
+ path = vsi_path(path)
559
567
 
560
568
  if driver is None:
561
569
  driver = detect_write_driver(path)
@@ -605,7 +613,8 @@ def write(
605
613
  ----------
606
614
  path : str or io.BytesIO
607
615
  path to output file on writeable file system or an io.BytesIO object to
608
- allow writing to memory
616
+ allow writing to memory. Will raise NotImplementedError if an open file
617
+ handle is passed; use BytesIO instead.
609
618
  NOTE: support for writing to memory is limited to specific drivers.
610
619
  geometry : ndarray of WKB encoded geometries or None
611
620
  If None, geometries will not be written to output file
@@ -677,6 +686,10 @@ def write(
677
686
  a key-value dictionary.
678
687
  gdal_tz_offsets : dict, optional (default: None)
679
688
  Used to handle GDAL timezone offsets for each field contained in dict.
689
+ **kwargs
690
+ Additional driver-specific dataset creation options passed to OGR. Invalid
691
+ options will trigger a warning.
692
+
680
693
  """
681
694
  # if dtypes is given, remove it from kwargs (dtypes is included in meta returned by
682
695
  # read, and it is convenient to pass meta directly into write for round trip tests)
@@ -698,7 +711,8 @@ def write(
698
711
  warnings.warn(
699
712
  "'crs' was not provided. The output dataset will not have "
700
713
  "projection information defined and may not be usable in other "
701
- "systems."
714
+ "systems.",
715
+ stacklevel=2,
702
716
  )
703
717
 
704
718
  # preprocess kwargs and split in dataset and layer creation options
@@ -745,8 +759,7 @@ def write_arrow(
745
759
  layer_options=None,
746
760
  **kwargs,
747
761
  ):
748
- """
749
- Write an Arrow-compatible data source to an OGR file format.
762
+ """Write an Arrow-compatible data source to an OGR file format.
750
763
 
751
764
  .. _Arrow PyCapsule Protocol: https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html
752
765
 
@@ -782,6 +795,8 @@ def write_arrow(
782
795
  type of the output file to this value. Use this parameter with caution because
783
796
  using a wrong layer geometry type may result in errors when writing the
784
797
  file, may be ignored by the driver, or may result in invalid files.
798
+ crs : str, optional (default: None)
799
+ WKT-encoded CRS of the geometries to be written.
785
800
  encoding : str, optional (default: None)
786
801
  Only used for the .dbf file of ESRI Shapefiles. If not specified,
787
802
  uses the default locale.
@@ -842,7 +857,8 @@ def write_arrow(
842
857
  warnings.warn(
843
858
  "'crs' was not provided. The output dataset will not have "
844
859
  "projection information defined and may not be usable in other "
845
- "systems."
860
+ "systems.",
861
+ stacklevel=2,
846
862
  )
847
863
 
848
864
  dataset_metadata, layer_metadata = _validate_metadata(