pyogrio 0.9.0__cp39-cp39-manylinux_2_28_aarch64.whl → 0.11.0__cp39-cp39-manylinux_2_28_aarch64.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/__init__.py +28 -21
  2. pyogrio/_compat.py +15 -1
  3. pyogrio/_env.py +4 -6
  4. pyogrio/_err.cpython-39-aarch64-linux-gnu.so +0 -0
  5. pyogrio/_geometry.cpython-39-aarch64-linux-gnu.so +0 -0
  6. pyogrio/_io.cpython-39-aarch64-linux-gnu.so +0 -0
  7. pyogrio/_ogr.cpython-39-aarch64-linux-gnu.so +0 -0
  8. pyogrio/_version.py +3 -3
  9. pyogrio/_vsi.cpython-39-aarch64-linux-gnu.so +0 -0
  10. pyogrio/core.py +86 -20
  11. pyogrio/errors.py +9 -16
  12. pyogrio/gdal_data/GDAL-targets-release.cmake +3 -3
  13. pyogrio/gdal_data/GDAL-targets.cmake +2 -2
  14. pyogrio/gdal_data/GDALConfig.cmake +0 -1
  15. pyogrio/gdal_data/GDALConfigVersion.cmake +3 -3
  16. pyogrio/gdal_data/MM_m_idofic.csv +321 -0
  17. pyogrio/gdal_data/gdalinfo_output.schema.json +3 -3
  18. pyogrio/gdal_data/gdaltileindex.xsd +253 -0
  19. pyogrio/gdal_data/gdalvrt.xsd +178 -63
  20. pyogrio/gdal_data/nitf_spec.xml +1 -17
  21. pyogrio/gdal_data/nitf_spec.xsd +1 -17
  22. pyogrio/gdal_data/ogrinfo_output.schema.json +23 -0
  23. pyogrio/gdal_data/ogrvrt.xsd +4 -17
  24. pyogrio/gdal_data/osmconf.ini +3 -1
  25. pyogrio/gdal_data/pci_datum.txt +222 -155
  26. pyogrio/gdal_data/pci_ellips.txt +90 -38
  27. pyogrio/gdal_data/pdfcomposition.xsd +1 -17
  28. pyogrio/gdal_data/vcpkg.spdx.json +32 -27
  29. pyogrio/gdal_data/vcpkg_abi_info.txt +30 -29
  30. pyogrio/gdal_data/vdv452.xml +1 -17
  31. pyogrio/gdal_data/vdv452.xsd +1 -17
  32. pyogrio/geopandas.py +122 -66
  33. pyogrio/proj_data/ITRF2014 +1 -1
  34. pyogrio/proj_data/ITRF2020 +91 -0
  35. pyogrio/proj_data/proj-config-version.cmake +2 -2
  36. pyogrio/proj_data/proj-config.cmake +1 -1
  37. pyogrio/proj_data/proj-targets.cmake +3 -3
  38. pyogrio/proj_data/proj.db +0 -0
  39. pyogrio/proj_data/proj.ini +11 -3
  40. pyogrio/proj_data/proj4-targets.cmake +3 -3
  41. pyogrio/proj_data/projjson.schema.json +1 -1
  42. pyogrio/proj_data/usage +7 -2
  43. pyogrio/proj_data/vcpkg.spdx.json +27 -22
  44. pyogrio/proj_data/vcpkg_abi_info.txt +17 -16
  45. pyogrio/raw.py +46 -30
  46. pyogrio/tests/conftest.py +214 -12
  47. pyogrio/tests/fixtures/README.md +32 -13
  48. pyogrio/tests/fixtures/curve.gpkg +0 -0
  49. pyogrio/tests/fixtures/{test_multisurface.gpkg → curvepolygon.gpkg} +0 -0
  50. pyogrio/tests/fixtures/line_zm.gpkg +0 -0
  51. pyogrio/tests/fixtures/multisurface.gpkg +0 -0
  52. pyogrio/tests/test_arrow.py +181 -24
  53. pyogrio/tests/test_core.py +170 -76
  54. pyogrio/tests/test_geopandas_io.py +483 -135
  55. pyogrio/tests/test_path.py +39 -17
  56. pyogrio/tests/test_raw_io.py +170 -55
  57. pyogrio/tests/test_util.py +56 -0
  58. pyogrio/util.py +69 -32
  59. pyogrio-0.11.0.dist-info/METADATA +124 -0
  60. {pyogrio-0.9.0.dist-info → pyogrio-0.11.0.dist-info}/RECORD +200 -214
  61. {pyogrio-0.9.0.dist-info → pyogrio-0.11.0.dist-info}/WHEEL +1 -1
  62. {pyogrio-0.9.0.dist-info → pyogrio-0.11.0.dist-info/licenses}/LICENSE +1 -1
  63. pyogrio.libs/{libgdal-6ff0914e.so.34.3.8.5 → libgdal-4bc0d15f.so.36.3.10.3} +0 -0
  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-linux-dynamic-release-9.4.0-a773fd97-43cc-4c8a-9729-d80537cf95e7",
7
- "name": "proj:arm64-linux-dynamic-release@9.4.0 2390d4ac09577aae072602ffa5778fb45348916244670786c8fb79324999d80b",
6
+ "documentNamespace": "https://spdx.org/spdxdocs/proj-arm64-linux-dynamic-release-9.6.0-3f98843c-877c-402e-b7ad-cf8428d5b113",
7
+ "name": "proj:arm64-linux-dynamic-release@9.6.0 348b35b1e6ddacb995d29f89e0c22ab0edbbcc90294221210a95e57198ae2879",
8
8
  "creationInfo": {
9
9
  "creators": [
10
- "Tool: vcpkg-unknownhash"
10
+ "Tool: vcpkg-2025-04-16-f9b6c6917b23c1ccf16c1a9f015ebabf8f615045"
11
11
  ],
12
- "created": "2024-06-17T19:13:34Z"
12
+ "created": "2025-05-08T14:53:44Z"
13
13
  },
14
14
  "relationships": [
15
15
  {
@@ -81,14 +81,19 @@
81
81
  "spdxElementId": "SPDXRef-file-5",
82
82
  "relationshipType": "CONTAINED_BY",
83
83
  "relatedSpdxElement": "SPDXRef-port"
84
+ },
85
+ {
86
+ "spdxElementId": "SPDXRef-file-5",
87
+ "relationshipType": "DEPENDENCY_MANIFEST_OF",
88
+ "relatedSpdxElement": "SPDXRef-port"
84
89
  }
85
90
  ],
86
91
  "packages": [
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-linux-dynamic-release",
101
106
  "SPDXID": "SPDXRef-binary",
102
- "versionInfo": "2390d4ac09577aae072602ffa5778fb45348916244670786c8fb79324999d80b",
107
+ "versionInfo": "348b35b1e6ddacb995d29f89e0c22ab0edbbcc90294221210a95e57198ae2879",
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": ".//opt/vcpkg/buildtrees/versioning_/versions/proj/62e9ace469641b907291184ebc7e76d96f629881/remove_toolset_restriction.patch",
131
+ "fileName": "./fix-proj4-targets-cmake.patch",
127
132
  "SPDXID": "SPDXRef-file-0",
128
133
  "checksums": [
129
134
  {
130
135
  "algorithm": "SHA256",
131
- "checksumValue": "25c1c986673bd539f5ec920684a08b38d0d37d9e24b6793e5b79dbd717bde04e"
136
+ "checksumValue": "d76e1d419d3367dda3381fd11a637f3465bc838d611fa8ceaca20048c1b3cd6e"
132
137
  }
133
138
  ],
134
139
  "licenseConcluded": "NOASSERTION",
135
140
  "copyrightText": "NOASSERTION"
136
141
  },
137
142
  {
138
- "fileName": ".//opt/vcpkg/buildtrees/versioning_/versions/proj/62e9ace469641b907291184ebc7e76d96f629881/portfile.cmake",
143
+ "fileName": "./remove_toolset_restriction.patch",
139
144
  "SPDXID": "SPDXRef-file-1",
140
145
  "checksums": [
141
146
  {
142
147
  "algorithm": "SHA256",
143
- "checksumValue": "58b4048cfc81891c1e32e41bc00b52ea7ae2821bd577b46ab63d2c962ef8747d"
148
+ "checksumValue": "25c1c986673bd539f5ec920684a08b38d0d37d9e24b6793e5b79dbd717bde04e"
144
149
  }
145
150
  ],
146
151
  "licenseConcluded": "NOASSERTION",
147
152
  "copyrightText": "NOASSERTION"
148
153
  },
149
154
  {
150
- "fileName": ".//opt/vcpkg/buildtrees/versioning_/versions/proj/62e9ace469641b907291184ebc7e76d96f629881/fix-win-output-name.patch",
155
+ "fileName": "./usage",
151
156
  "SPDXID": "SPDXRef-file-2",
152
157
  "checksums": [
153
158
  {
154
159
  "algorithm": "SHA256",
155
- "checksumValue": "706e536cfe9a90c1b071ab5b00932fa96bb35c67fcb0f96c0fc4feb7c0b44011"
160
+ "checksumValue": "ae06beae83376cd9f11db8c2596bd038f89ae1e2cd32b82ee333f1572070370a"
156
161
  }
157
162
  ],
158
163
  "licenseConcluded": "NOASSERTION",
159
164
  "copyrightText": "NOASSERTION"
160
165
  },
161
166
  {
162
- "fileName": ".//opt/vcpkg/buildtrees/versioning_/versions/proj/62e9ace469641b907291184ebc7e76d96f629881/usage",
167
+ "fileName": "./portfile.cmake",
163
168
  "SPDXID": "SPDXRef-file-3",
164
169
  "checksums": [
165
170
  {
166
171
  "algorithm": "SHA256",
167
- "checksumValue": "26169363c27e71a44cba9d703b22bbd13c191ab5e2d0612b3dd35c735c971fe6"
172
+ "checksumValue": "5fd54e02ca8ceda95178cb097182d81c5e10590cb15f74c1f67ed328eab84af2"
168
173
  }
169
174
  ],
170
175
  "licenseConcluded": "NOASSERTION",
171
176
  "copyrightText": "NOASSERTION"
172
177
  },
173
178
  {
174
- "fileName": ".//opt/vcpkg/buildtrees/versioning_/versions/proj/62e9ace469641b907291184ebc7e76d96f629881/fix-proj4-targets-cmake.patch",
179
+ "fileName": "./sqlite.diff",
175
180
  "SPDXID": "SPDXRef-file-4",
176
181
  "checksums": [
177
182
  {
178
183
  "algorithm": "SHA256",
179
- "checksumValue": "d76e1d419d3367dda3381fd11a637f3465bc838d611fa8ceaca20048c1b3cd6e"
184
+ "checksumValue": "75049bf707593bb9a22a6f77ccc062fe1343484a12920adc7be5c29c14746857"
180
185
  }
181
186
  ],
182
187
  "licenseConcluded": "NOASSERTION",
183
188
  "copyrightText": "NOASSERTION"
184
189
  },
185
190
  {
186
- "fileName": ".//opt/vcpkg/buildtrees/versioning_/versions/proj/62e9ace469641b907291184ebc7e76d96f629881/vcpkg.json",
191
+ "fileName": "./vcpkg.json",
187
192
  "SPDXID": "SPDXRef-file-5",
188
193
  "checksums": [
189
194
  {
190
195
  "algorithm": "SHA256",
191
- "checksumValue": "d31d1d3beb5ef0890e4b5db1ee5b72a925a58aa53bfaee688d4b5af1cea2bba4"
196
+ "checksumValue": "88ecc073bf74d5a0a114bb1357499f6210c84a4f5a8b7beed2af94907f2f8802"
192
197
  }
193
198
  ],
194
199
  "licenseConcluded": "NOASSERTION",
@@ -1,27 +1,28 @@
1
1
  cmake 0
2
- curl a4bb1e391f21be499648a3a0a32ee4f36324626dbf020b1dab1415568e114f9c
2
+ curl cd91820052c5cabfc1071ef2e315d5ffb8df212645994cfb2e46e60d7fd331c9
3
3
  features core;net;tiff
4
4
  fix-proj4-targets-cmake.patch d76e1d419d3367dda3381fd11a637f3465bc838d611fa8ceaca20048c1b3cd6e
5
- fix-win-output-name.patch 706e536cfe9a90c1b071ab5b00932fa96bb35c67fcb0f96c0fc4feb7c0b44011
6
- nlohmann-json 9494e51d107559a7e8b556eab74d802b962f02631e8dc1011a0fdf52d4735149
7
- portfile.cmake 58b4048cfc81891c1e32e41bc00b52ea7ae2821bd577b46ab63d2c962ef8747d
8
- ports.cmake 0500e9e2422fe0084c99bdd0c9de4c7069b76da14c8b58228a7e95ebac43058a
5
+ nlohmann-json 954441e704eb380a65016bee26dcbcad6bfb6b7fcc5b9798634756fa28e44a6f
6
+ portfile.cmake 5fd54e02ca8ceda95178cb097182d81c5e10590cb15f74c1f67ed328eab84af2
7
+ ports.cmake a9f8f745f9f4d225039f9810e79670f10f38c7455222865616ce430a06f75d1f
9
8
  post_build_checks 2
10
9
  remove_toolset_restriction.patch 25c1c986673bd539f5ec920684a08b38d0d37d9e24b6793e5b79dbd717bde04e
11
- sqlite3 666d04f1a5112d84de49a03ad7dcaf3ab9f8e63999848b489b78c68e5e9203c6
12
- sqlite3 fc728bd923a34a7b8be9b38b3ed152228a9bc12be18cc566db5e36174ddfed2f
13
- tiff 8b3b88e683e77b633f425d6bb45e77476c87b3408b705d50af225b521d37d0bd
10
+ sqlite.diff 75049bf707593bb9a22a6f77ccc062fe1343484a12920adc7be5c29c14746857
11
+ sqlite3 992583566108959150284e905c28253a6f8ceb2966469b5f1671a6290aa5bbef
12
+ sqlite3 c4c6516c985c071858a60e59e8a55c84d76df40b88e6877d8730429dffd48c52
13
+ tiff 523d46f94adc7c2ae348e5df2d96c9ea9302074cf92f4921a773596d55ce202c
14
14
  triplet arm64-linux-dynamic-release
15
- triplet_abi a2978ef94e01dd995e28fd3fc9d73a99d96cda95c172e0f1d199230f0e1bcdce-73c4f253fe835be7b4f68430dabc1102ae8e82e9ab34e9b6dbec047dc9b6447d-2ad07b68ec1acd5ddac23c4df04ffe712cc82a8d
16
- usage 26169363c27e71a44cba9d703b22bbd13c191ab5e2d0612b3dd35c735c971fe6
17
- vcpkg-cmake 61a6b5861674f41494b4ebae1f315674d62a4f6f2002093c13c2750ef3b2221e
18
- vcpkg-cmake-config 67c57a7501cf304cee2b318a14b5763968eb7ae54bc621edbe4ea197119243b6
19
- vcpkg.json d31d1d3beb5ef0890e4b5db1ee5b72a925a58aa53bfaee688d4b5af1cea2bba4
15
+ triplet_abi a2978ef94e01dd995e28fd3fc9d73a99d96cda95c172e0f1d199230f0e1bcdce-7300d6fc76582335b0d9fd6dc6a00f69d7ba728b9d6444ad2a9d42f054e1d991-74c8e394d0e73248df1e0668d914ff6b718e7a09
16
+ usage ae06beae83376cd9f11db8c2596bd038f89ae1e2cd32b82ee333f1572070370a
17
+ vcpkg-cmake a79c21e39eef27f214b8b5336b87655ab057fc471392d4b93a5d289d903644f1
18
+ vcpkg-cmake-config 74889bcdb08699240b376f5c1546060ab9b2e21a3c7d5818beabe6166fd915ab
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(