pyogrio 0.12.0__cp314-cp314t-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.
Files changed (231) hide show
  1. pyogrio/.dylibs/libgdal.37.3.11.4.dylib +0 -0
  2. pyogrio/__init__.py +57 -0
  3. pyogrio/_compat.py +54 -0
  4. pyogrio/_env.py +59 -0
  5. pyogrio/_err.cpython-314t-darwin.so +0 -0
  6. pyogrio/_geometry.cpython-314t-darwin.so +0 -0
  7. pyogrio/_io.cpython-314t-darwin.so +0 -0
  8. pyogrio/_ogr.cpython-314t-darwin.so +0 -0
  9. pyogrio/_version.py +21 -0
  10. pyogrio/_vsi.cpython-314t-darwin.so +0 -0
  11. pyogrio/core.py +387 -0
  12. pyogrio/errors.py +25 -0
  13. pyogrio/gdal_data/GDAL-targets-release.cmake +19 -0
  14. pyogrio/gdal_data/GDAL-targets.cmake +106 -0
  15. pyogrio/gdal_data/GDALConfig.cmake +24 -0
  16. pyogrio/gdal_data/GDALConfigVersion.cmake +65 -0
  17. pyogrio/gdal_data/GDALLogoBW.svg +138 -0
  18. pyogrio/gdal_data/GDALLogoColor.svg +126 -0
  19. pyogrio/gdal_data/GDALLogoGS.svg +126 -0
  20. pyogrio/gdal_data/LICENSE.TXT +467 -0
  21. pyogrio/gdal_data/MM_m_idofic.csv +321 -0
  22. pyogrio/gdal_data/copyright +467 -0
  23. pyogrio/gdal_data/cubewerx_extra.wkt +48 -0
  24. pyogrio/gdal_data/default.rsc +0 -0
  25. pyogrio/gdal_data/ecw_cs.wkt +1453 -0
  26. pyogrio/gdal_data/eedaconf.json +23 -0
  27. pyogrio/gdal_data/epsg.wkt +1 -0
  28. pyogrio/gdal_data/esri_StatePlane_extra.wkt +631 -0
  29. pyogrio/gdal_data/gdal_algorithm.schema.json +220 -0
  30. pyogrio/gdal_data/gdalg.schema.json +36 -0
  31. pyogrio/gdal_data/gdalicon.png +0 -0
  32. pyogrio/gdal_data/gdalinfo_output.schema.json +390 -0
  33. pyogrio/gdal_data/gdalmdiminfo_output.schema.json +326 -0
  34. pyogrio/gdal_data/gdaltileindex.xsd +253 -0
  35. pyogrio/gdal_data/gdalvrt.xsd +927 -0
  36. pyogrio/gdal_data/gfs.xsd +246 -0
  37. pyogrio/gdal_data/gml_registry.xml +117 -0
  38. pyogrio/gdal_data/gml_registry.xsd +66 -0
  39. pyogrio/gdal_data/grib2_center.csv +251 -0
  40. pyogrio/gdal_data/grib2_process.csv +102 -0
  41. pyogrio/gdal_data/grib2_subcenter.csv +63 -0
  42. pyogrio/gdal_data/grib2_table_4_2_0_0.csv +261 -0
  43. pyogrio/gdal_data/grib2_table_4_2_0_1.csv +261 -0
  44. pyogrio/gdal_data/grib2_table_4_2_0_13.csv +261 -0
  45. pyogrio/gdal_data/grib2_table_4_2_0_14.csv +261 -0
  46. pyogrio/gdal_data/grib2_table_4_2_0_15.csv +261 -0
  47. pyogrio/gdal_data/grib2_table_4_2_0_16.csv +261 -0
  48. pyogrio/gdal_data/grib2_table_4_2_0_17.csv +11 -0
  49. pyogrio/gdal_data/grib2_table_4_2_0_18.csv +261 -0
  50. pyogrio/gdal_data/grib2_table_4_2_0_19.csv +261 -0
  51. pyogrio/gdal_data/grib2_table_4_2_0_190.csv +261 -0
  52. pyogrio/gdal_data/grib2_table_4_2_0_191.csv +261 -0
  53. pyogrio/gdal_data/grib2_table_4_2_0_2.csv +261 -0
  54. pyogrio/gdal_data/grib2_table_4_2_0_20.csv +261 -0
  55. pyogrio/gdal_data/grib2_table_4_2_0_21.csv +261 -0
  56. pyogrio/gdal_data/grib2_table_4_2_0_3.csv +261 -0
  57. pyogrio/gdal_data/grib2_table_4_2_0_4.csv +261 -0
  58. pyogrio/gdal_data/grib2_table_4_2_0_5.csv +261 -0
  59. pyogrio/gdal_data/grib2_table_4_2_0_6.csv +261 -0
  60. pyogrio/gdal_data/grib2_table_4_2_0_7.csv +261 -0
  61. pyogrio/gdal_data/grib2_table_4_2_10_0.csv +261 -0
  62. pyogrio/gdal_data/grib2_table_4_2_10_1.csv +261 -0
  63. pyogrio/gdal_data/grib2_table_4_2_10_191.csv +261 -0
  64. pyogrio/gdal_data/grib2_table_4_2_10_2.csv +261 -0
  65. pyogrio/gdal_data/grib2_table_4_2_10_3.csv +261 -0
  66. pyogrio/gdal_data/grib2_table_4_2_10_4.csv +261 -0
  67. pyogrio/gdal_data/grib2_table_4_2_1_0.csv +261 -0
  68. pyogrio/gdal_data/grib2_table_4_2_1_1.csv +261 -0
  69. pyogrio/gdal_data/grib2_table_4_2_1_2.csv +261 -0
  70. pyogrio/gdal_data/grib2_table_4_2_20_0.csv +261 -0
  71. pyogrio/gdal_data/grib2_table_4_2_20_1.csv +261 -0
  72. pyogrio/gdal_data/grib2_table_4_2_20_2.csv +261 -0
  73. pyogrio/gdal_data/grib2_table_4_2_2_0.csv +261 -0
  74. pyogrio/gdal_data/grib2_table_4_2_2_3.csv +261 -0
  75. pyogrio/gdal_data/grib2_table_4_2_2_4.csv +261 -0
  76. pyogrio/gdal_data/grib2_table_4_2_2_5.csv +261 -0
  77. pyogrio/gdal_data/grib2_table_4_2_2_6.csv +261 -0
  78. pyogrio/gdal_data/grib2_table_4_2_3_0.csv +261 -0
  79. pyogrio/gdal_data/grib2_table_4_2_3_1.csv +261 -0
  80. pyogrio/gdal_data/grib2_table_4_2_3_2.csv +28 -0
  81. pyogrio/gdal_data/grib2_table_4_2_3_3.csv +8 -0
  82. pyogrio/gdal_data/grib2_table_4_2_3_4.csv +14 -0
  83. pyogrio/gdal_data/grib2_table_4_2_3_5.csv +11 -0
  84. pyogrio/gdal_data/grib2_table_4_2_3_6.csv +11 -0
  85. pyogrio/gdal_data/grib2_table_4_2_4_0.csv +261 -0
  86. pyogrio/gdal_data/grib2_table_4_2_4_1.csv +261 -0
  87. pyogrio/gdal_data/grib2_table_4_2_4_10.csv +261 -0
  88. pyogrio/gdal_data/grib2_table_4_2_4_2.csv +261 -0
  89. pyogrio/gdal_data/grib2_table_4_2_4_3.csv +261 -0
  90. pyogrio/gdal_data/grib2_table_4_2_4_4.csv +261 -0
  91. pyogrio/gdal_data/grib2_table_4_2_4_5.csv +261 -0
  92. pyogrio/gdal_data/grib2_table_4_2_4_6.csv +261 -0
  93. pyogrio/gdal_data/grib2_table_4_2_4_7.csv +261 -0
  94. pyogrio/gdal_data/grib2_table_4_2_4_8.csv +261 -0
  95. pyogrio/gdal_data/grib2_table_4_2_4_9.csv +261 -0
  96. pyogrio/gdal_data/grib2_table_4_2_local_Canada.csv +5 -0
  97. pyogrio/gdal_data/grib2_table_4_2_local_HPC.csv +2 -0
  98. pyogrio/gdal_data/grib2_table_4_2_local_MRMS.csv +175 -0
  99. pyogrio/gdal_data/grib2_table_4_2_local_NCEP.csv +401 -0
  100. pyogrio/gdal_data/grib2_table_4_2_local_NDFD.csv +38 -0
  101. pyogrio/gdal_data/grib2_table_4_2_local_index.csv +7 -0
  102. pyogrio/gdal_data/grib2_table_4_5.csv +261 -0
  103. pyogrio/gdal_data/grib2_table_versions.csv +3 -0
  104. pyogrio/gdal_data/gt_datum.csv +229 -0
  105. pyogrio/gdal_data/gt_ellips.csv +24 -0
  106. pyogrio/gdal_data/header.dxf +1124 -0
  107. pyogrio/gdal_data/inspire_cp_BasicPropertyUnit.gfs +57 -0
  108. pyogrio/gdal_data/inspire_cp_CadastralBoundary.gfs +60 -0
  109. pyogrio/gdal_data/inspire_cp_CadastralParcel.gfs +81 -0
  110. pyogrio/gdal_data/inspire_cp_CadastralZoning.gfs +161 -0
  111. pyogrio/gdal_data/jpfgdgml_AdmArea.gfs +59 -0
  112. pyogrio/gdal_data/jpfgdgml_AdmBdry.gfs +49 -0
  113. pyogrio/gdal_data/jpfgdgml_AdmPt.gfs +59 -0
  114. pyogrio/gdal_data/jpfgdgml_BldA.gfs +54 -0
  115. pyogrio/gdal_data/jpfgdgml_BldL.gfs +54 -0
  116. pyogrio/gdal_data/jpfgdgml_Cntr.gfs +54 -0
  117. pyogrio/gdal_data/jpfgdgml_CommBdry.gfs +49 -0
  118. pyogrio/gdal_data/jpfgdgml_CommPt.gfs +59 -0
  119. pyogrio/gdal_data/jpfgdgml_Cstline.gfs +54 -0
  120. pyogrio/gdal_data/jpfgdgml_ElevPt.gfs +54 -0
  121. pyogrio/gdal_data/jpfgdgml_GCP.gfs +94 -0
  122. pyogrio/gdal_data/jpfgdgml_LeveeEdge.gfs +49 -0
  123. pyogrio/gdal_data/jpfgdgml_RailCL.gfs +54 -0
  124. pyogrio/gdal_data/jpfgdgml_RdASL.gfs +44 -0
  125. pyogrio/gdal_data/jpfgdgml_RdArea.gfs +54 -0
  126. pyogrio/gdal_data/jpfgdgml_RdCompt.gfs +59 -0
  127. pyogrio/gdal_data/jpfgdgml_RdEdg.gfs +59 -0
  128. pyogrio/gdal_data/jpfgdgml_RdMgtBdry.gfs +49 -0
  129. pyogrio/gdal_data/jpfgdgml_RdSgmtA.gfs +59 -0
  130. pyogrio/gdal_data/jpfgdgml_RvrMgtBdry.gfs +49 -0
  131. pyogrio/gdal_data/jpfgdgml_SBAPt.gfs +49 -0
  132. pyogrio/gdal_data/jpfgdgml_SBArea.gfs +54 -0
  133. pyogrio/gdal_data/jpfgdgml_SBBdry.gfs +44 -0
  134. pyogrio/gdal_data/jpfgdgml_WA.gfs +54 -0
  135. pyogrio/gdal_data/jpfgdgml_WL.gfs +54 -0
  136. pyogrio/gdal_data/jpfgdgml_WStrA.gfs +54 -0
  137. pyogrio/gdal_data/jpfgdgml_WStrL.gfs +54 -0
  138. pyogrio/gdal_data/leaflet_template.html +102 -0
  139. pyogrio/gdal_data/nitf_spec.xml +3288 -0
  140. pyogrio/gdal_data/nitf_spec.xsd +171 -0
  141. pyogrio/gdal_data/ogr_fields_override.schema.json +125 -0
  142. pyogrio/gdal_data/ogrinfo_output.schema.json +528 -0
  143. pyogrio/gdal_data/ogrvrt.xsd +528 -0
  144. pyogrio/gdal_data/osmconf.ini +134 -0
  145. pyogrio/gdal_data/ozi_datum.csv +131 -0
  146. pyogrio/gdal_data/ozi_ellips.csv +35 -0
  147. pyogrio/gdal_data/pci_datum.txt +530 -0
  148. pyogrio/gdal_data/pci_ellips.txt +129 -0
  149. pyogrio/gdal_data/pdfcomposition.xsd +703 -0
  150. pyogrio/gdal_data/pds4_template.xml +65 -0
  151. pyogrio/gdal_data/plscenesconf.json +1985 -0
  152. pyogrio/gdal_data/ruian_vf_ob_v1.gfs +1455 -0
  153. pyogrio/gdal_data/ruian_vf_st_uvoh_v1.gfs +86 -0
  154. pyogrio/gdal_data/ruian_vf_st_v1.gfs +1489 -0
  155. pyogrio/gdal_data/ruian_vf_v1.gfs +2126 -0
  156. pyogrio/gdal_data/s57agencies.csv +249 -0
  157. pyogrio/gdal_data/s57attributes.csv +484 -0
  158. pyogrio/gdal_data/s57expectedinput.csv +1008 -0
  159. pyogrio/gdal_data/s57objectclasses.csv +287 -0
  160. pyogrio/gdal_data/seed_2d.dgn +0 -0
  161. pyogrio/gdal_data/seed_3d.dgn +0 -0
  162. pyogrio/gdal_data/stateplane.csv +259 -0
  163. pyogrio/gdal_data/template_tiles.mapml +28 -0
  164. pyogrio/gdal_data/tms_LINZAntarticaMapTileGrid.json +190 -0
  165. pyogrio/gdal_data/tms_MapML_APSTILE.json +268 -0
  166. pyogrio/gdal_data/tms_MapML_CBMTILE.json +346 -0
  167. pyogrio/gdal_data/tms_NZTM2000.json +243 -0
  168. pyogrio/gdal_data/trailer.dxf +434 -0
  169. pyogrio/gdal_data/usage +4 -0
  170. pyogrio/gdal_data/vcpkg-cmake-wrapper.cmake +23 -0
  171. pyogrio/gdal_data/vcpkg.spdx.json +291 -0
  172. pyogrio/gdal_data/vcpkg_abi_info.txt +45 -0
  173. pyogrio/gdal_data/vdv452.xml +349 -0
  174. pyogrio/gdal_data/vdv452.xsd +45 -0
  175. pyogrio/gdal_data/vicar.json +164 -0
  176. pyogrio/geopandas.py +978 -0
  177. pyogrio/proj_data/CH +22 -0
  178. pyogrio/proj_data/GL27 +23 -0
  179. pyogrio/proj_data/ITRF2000 +24 -0
  180. pyogrio/proj_data/ITRF2008 +94 -0
  181. pyogrio/proj_data/ITRF2014 +55 -0
  182. pyogrio/proj_data/ITRF2020 +91 -0
  183. pyogrio/proj_data/copyright +34 -0
  184. pyogrio/proj_data/deformation_model.schema.json +582 -0
  185. pyogrio/proj_data/nad.lst +142 -0
  186. pyogrio/proj_data/nad27 +810 -0
  187. pyogrio/proj_data/nad83 +745 -0
  188. pyogrio/proj_data/other.extra +53 -0
  189. pyogrio/proj_data/proj-config-version.cmake +44 -0
  190. pyogrio/proj_data/proj-config.cmake +79 -0
  191. pyogrio/proj_data/proj-targets-release.cmake +19 -0
  192. pyogrio/proj_data/proj-targets.cmake +107 -0
  193. pyogrio/proj_data/proj.db +0 -0
  194. pyogrio/proj_data/proj.ini +59 -0
  195. pyogrio/proj_data/proj4-targets-release.cmake +19 -0
  196. pyogrio/proj_data/proj4-targets.cmake +107 -0
  197. pyogrio/proj_data/projjson.schema.json +1174 -0
  198. pyogrio/proj_data/triangulation.schema.json +214 -0
  199. pyogrio/proj_data/usage +9 -0
  200. pyogrio/proj_data/vcpkg.spdx.json +203 -0
  201. pyogrio/proj_data/vcpkg_abi_info.txt +28 -0
  202. pyogrio/proj_data/world +214 -0
  203. pyogrio/raw.py +897 -0
  204. pyogrio/tests/__init__.py +0 -0
  205. pyogrio/tests/conftest.py +588 -0
  206. pyogrio/tests/fixtures/README.md +108 -0
  207. pyogrio/tests/fixtures/curve.gpkg +0 -0
  208. pyogrio/tests/fixtures/curvepolygon.gpkg +0 -0
  209. pyogrio/tests/fixtures/line_zm.gpkg +0 -0
  210. pyogrio/tests/fixtures/list_field_values_file.parquet +0 -0
  211. pyogrio/tests/fixtures/list_nested_struct_file.parquet +0 -0
  212. pyogrio/tests/fixtures/multisurface.gpkg +0 -0
  213. pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.cpg +1 -0
  214. pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.dbf +0 -0
  215. pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.prj +1 -0
  216. pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shp +0 -0
  217. pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shx +0 -0
  218. pyogrio/tests/fixtures/sample.osm.pbf +0 -0
  219. pyogrio/tests/fixtures/test_gpkg_nulls.gpkg +0 -0
  220. pyogrio/tests/test_arrow.py +1160 -0
  221. pyogrio/tests/test_core.py +702 -0
  222. pyogrio/tests/test_geopandas_io.py +3218 -0
  223. pyogrio/tests/test_path.py +374 -0
  224. pyogrio/tests/test_raw_io.py +1473 -0
  225. pyogrio/tests/test_util.py +56 -0
  226. pyogrio/util.py +258 -0
  227. pyogrio-0.12.0.dist-info/METADATA +125 -0
  228. pyogrio-0.12.0.dist-info/RECORD +231 -0
  229. pyogrio-0.12.0.dist-info/WHEEL +6 -0
  230. pyogrio-0.12.0.dist-info/licenses/LICENSE +21 -0
  231. pyogrio-0.12.0.dist-info/top_level.txt +1 -0
Binary file
pyogrio/__init__.py ADDED
@@ -0,0 +1,57 @@
1
+ """Vectorized vector I/O using OGR."""
2
+
3
+ try:
4
+ # we try importing shapely, to ensure it is imported (and it can load its
5
+ # own GEOS copy) before we load GDAL and its linked GEOS
6
+ import shapely
7
+
8
+ if shapely.__version__ < "2.0.0":
9
+ import shapely.geos
10
+ except Exception:
11
+ pass
12
+
13
+ from pyogrio._version import get_versions
14
+ from pyogrio.core import (
15
+ __gdal_geos_version__,
16
+ __gdal_version__,
17
+ __gdal_version_string__,
18
+ detect_write_driver,
19
+ get_gdal_config_option,
20
+ get_gdal_data_path,
21
+ list_drivers,
22
+ list_layers,
23
+ read_bounds,
24
+ read_info,
25
+ set_gdal_config_options,
26
+ vsi_listtree,
27
+ vsi_rmtree,
28
+ vsi_unlink,
29
+ )
30
+ from pyogrio.geopandas import read_dataframe, write_dataframe
31
+ from pyogrio.raw import open_arrow, read_arrow, write_arrow
32
+
33
+ __version__ = get_versions()["version"]
34
+ del get_versions
35
+
36
+ __all__ = [
37
+ "__gdal_geos_version__",
38
+ "__gdal_version__",
39
+ "__gdal_version_string__",
40
+ "__version__",
41
+ "detect_write_driver",
42
+ "get_gdal_config_option",
43
+ "get_gdal_data_path",
44
+ "list_drivers",
45
+ "list_layers",
46
+ "open_arrow",
47
+ "read_arrow",
48
+ "read_bounds",
49
+ "read_dataframe",
50
+ "read_info",
51
+ "set_gdal_config_options",
52
+ "vsi_listtree",
53
+ "vsi_rmtree",
54
+ "vsi_unlink",
55
+ "write_arrow",
56
+ "write_dataframe",
57
+ ]
pyogrio/_compat.py ADDED
@@ -0,0 +1,54 @@
1
+ from packaging.version import Version
2
+
3
+ from pyogrio.core import __gdal_geos_version__, __gdal_version__
4
+
5
+ # detect optional dependencies
6
+ try:
7
+ import pyarrow
8
+ except ImportError:
9
+ pyarrow = None
10
+
11
+ try:
12
+ import pyproj
13
+ except ImportError:
14
+ pyproj = None
15
+
16
+ try:
17
+ import shapely
18
+ except ImportError:
19
+ shapely = None
20
+
21
+ try:
22
+ import geopandas
23
+ except ImportError:
24
+ geopandas = None
25
+
26
+ try:
27
+ import pandas
28
+ except ImportError:
29
+ pandas = None
30
+
31
+
32
+ HAS_ARROW_WRITE_API = __gdal_version__ >= (3, 8, 0)
33
+ HAS_PYARROW = pyarrow is not None
34
+ HAS_PYPROJ = pyproj is not None
35
+ PYARROW_GE_19 = pyarrow is not None and Version(pyarrow.__version__) >= Version(
36
+ "19.0.0"
37
+ )
38
+
39
+ HAS_GEOPANDAS = geopandas is not None
40
+
41
+ PANDAS_GE_15 = pandas is not None and Version(pandas.__version__) >= Version("1.5.0")
42
+ PANDAS_GE_20 = pandas is not None and Version(pandas.__version__) >= Version("2.0.0")
43
+ PANDAS_GE_22 = pandas is not None and Version(pandas.__version__) >= Version("2.2.0")
44
+ PANDAS_GE_23 = pandas is not None and Version(pandas.__version__) >= Version("2.3.0")
45
+ PANDAS_GE_30 = pandas is not None and Version(pandas.__version__) >= Version("3.0.0dev")
46
+
47
+ GDAL_GE_37 = __gdal_version__ >= (3, 7, 0)
48
+ GDAL_GE_38 = __gdal_version__ >= (3, 8, 0)
49
+ GDAL_GE_311 = __gdal_version__ >= (3, 11, 0)
50
+
51
+ HAS_GDAL_GEOS = __gdal_geos_version__ is not None
52
+
53
+ HAS_SHAPELY = shapely is not None and Version(shapely.__version__) >= Version("2.0.0")
54
+ SHAPELY_GE_21 = shapely is not None and Version(shapely.__version__) >= Version("2.1.0")
pyogrio/_env.py ADDED
@@ -0,0 +1,59 @@
1
+ # With Python >= 3.8 on Windows directories in PATH are not automatically
2
+ # searched for DLL dependencies and must be added manually with
3
+ # os.add_dll_directory.
4
+ # adapted from Fiona: https://github.com/Toblerity/Fiona/pull/875
5
+
6
+
7
+ import logging
8
+ import os
9
+ import platform
10
+ from contextlib import contextmanager
11
+ from pathlib import Path
12
+
13
+ log = logging.getLogger(__name__)
14
+ log.addHandler(logging.NullHandler())
15
+
16
+
17
+ try:
18
+ # set GDAL_CURL_CA_BUNDLE / PROJ_CURL_CA_BUNDLE for GDAL >= 3.2
19
+ import certifi
20
+
21
+ ca_bundle = certifi.where()
22
+ os.environ.setdefault("GDAL_CURL_CA_BUNDLE", ca_bundle)
23
+ os.environ.setdefault("PROJ_CURL_CA_BUNDLE", ca_bundle)
24
+ except ImportError:
25
+ pass
26
+
27
+
28
+ gdal_dll_dir = None
29
+
30
+ if platform.system() == "Windows":
31
+ # if loading of extension modules fails, search for gdal dll directory
32
+ try:
33
+ import pyogrio._io # noqa: F401
34
+
35
+ except ImportError:
36
+ for path in os.getenv("PATH", "").split(os.pathsep):
37
+ if list(Path(path).glob("gdal*.dll")):
38
+ log.info(f"Found GDAL at {path}")
39
+ gdal_dll_dir = path
40
+ break
41
+
42
+ if not gdal_dll_dir:
43
+ raise ImportError(
44
+ "GDAL DLL could not be found. It must be on the system PATH."
45
+ )
46
+
47
+
48
+ @contextmanager
49
+ def GDALEnv():
50
+ dll_dir = None
51
+
52
+ if gdal_dll_dir:
53
+ dll_dir = os.add_dll_directory(gdal_dll_dir)
54
+
55
+ try:
56
+ yield None
57
+ finally:
58
+ if dll_dir is not None:
59
+ dll_dir.close()
Binary file
Binary file
Binary file
Binary file
pyogrio/_version.py ADDED
@@ -0,0 +1,21 @@
1
+
2
+ # This file was generated by 'versioneer.py' (0.28) from
3
+ # revision-control system data, or from the parent directory name of an
4
+ # unpacked source archive. Distribution tarballs contain a pre-generated copy
5
+ # of this file.
6
+
7
+ import json
8
+
9
+ version_json = '''
10
+ {
11
+ "date": "2025-11-26T10:18:55+0100",
12
+ "dirty": false,
13
+ "error": null,
14
+ "full-revisionid": "ea9a97b6aef45c921ea36b599666e7e83b84070c",
15
+ "version": "0.12.0"
16
+ }
17
+ ''' # END VERSION_JSON
18
+
19
+
20
+ def get_versions():
21
+ return json.loads(version_json)
Binary file
pyogrio/core.py ADDED
@@ -0,0 +1,387 @@
1
+ """Core functions to interact with OGR data sources."""
2
+
3
+ from pathlib import Path
4
+
5
+ from pyogrio._env import GDALEnv
6
+ from pyogrio.util import (
7
+ _mask_to_wkb,
8
+ _preprocess_options_key_value,
9
+ get_vsi_path_or_buffer,
10
+ )
11
+
12
+ with GDALEnv():
13
+ from pyogrio._err import _register_error_handler
14
+ from pyogrio._io import ogr_list_layers, ogr_read_bounds, ogr_read_info
15
+ from pyogrio._ogr import (
16
+ _get_drivers_for_path,
17
+ _register_drivers,
18
+ get_gdal_config_option as _get_gdal_config_option,
19
+ get_gdal_data_path as _get_gdal_data_path,
20
+ get_gdal_geos_version,
21
+ get_gdal_version,
22
+ get_gdal_version_string,
23
+ init_gdal_data as _init_gdal_data,
24
+ init_proj_data as _init_proj_data,
25
+ ogr_list_drivers,
26
+ set_gdal_config_options as _set_gdal_config_options,
27
+ )
28
+ from pyogrio._vsi import (
29
+ ogr_vsi_listtree,
30
+ ogr_vsi_rmtree,
31
+ ogr_vsi_unlink,
32
+ )
33
+
34
+ _init_gdal_data()
35
+ _init_proj_data()
36
+ _register_drivers()
37
+ _register_error_handler()
38
+
39
+ __gdal_version__ = get_gdal_version()
40
+ __gdal_version_string__ = get_gdal_version_string()
41
+ __gdal_geos_version__ = get_gdal_geos_version()
42
+
43
+
44
+ def list_drivers(read=False, write=False):
45
+ """List drivers available in GDAL.
46
+
47
+ Parameters
48
+ ----------
49
+ read: bool, optional (default: False)
50
+ If True, will only return drivers that are known to support read capabilities.
51
+ write: bool, optional (default: False)
52
+ If True, will only return drivers that are known to support write capabilities.
53
+
54
+ Returns
55
+ -------
56
+ dict
57
+ Mapping of driver name to file mode capabilities: ``"r"``: read, ``"w"``: write.
58
+ Drivers that are available but with unknown support are marked with ``"?"``
59
+
60
+ """
61
+ drivers = ogr_list_drivers()
62
+
63
+ if read:
64
+ drivers = {k: v for k, v in drivers.items() if v.startswith("r")}
65
+
66
+ if write:
67
+ drivers = {k: v for k, v in drivers.items() if v.endswith("w")}
68
+
69
+ return drivers
70
+
71
+
72
+ def detect_write_driver(path):
73
+ """Attempt to infer the driver for a path by extension or prefix.
74
+
75
+ Only drivers that support write capabilities will be detected.
76
+
77
+ If the path cannot be resolved to a single driver, a ValueError will be
78
+ raised.
79
+
80
+ Parameters
81
+ ----------
82
+ path : str
83
+ data source path
84
+
85
+ Returns
86
+ -------
87
+ str
88
+ name of the driver, if detected
89
+
90
+ """
91
+ # try to infer driver from path
92
+ drivers = _get_drivers_for_path(path)
93
+
94
+ if len(drivers) == 0:
95
+ raise ValueError(
96
+ f"Could not infer driver from path: {path}; please specify driver "
97
+ "explicitly"
98
+ )
99
+
100
+ # if there are multiple drivers detected, user needs to specify the correct
101
+ # one manually
102
+ elif len(drivers) > 1:
103
+ raise ValueError(
104
+ f"Could not infer driver from path: {path}; multiple drivers are "
105
+ f"available for that extension: {', '.join(drivers)}. Please "
106
+ "specify driver explicitly."
107
+ )
108
+
109
+ return drivers[0]
110
+
111
+
112
+ def list_layers(path_or_buffer, /):
113
+ """List layers available in an OGR data source.
114
+
115
+ NOTE: includes both spatial and nonspatial layers.
116
+
117
+ Parameters
118
+ ----------
119
+ path_or_buffer : str, pathlib.Path, bytes, or file-like
120
+ A dataset path or URI, raw buffer, or file-like object with a read method.
121
+
122
+ Returns
123
+ -------
124
+ ndarray shape (2, n)
125
+ array of pairs of [<layer name>, <layer geometry type>]
126
+ Note: geometry is `None` for nonspatial layers.
127
+
128
+ """
129
+ return ogr_list_layers(get_vsi_path_or_buffer(path_or_buffer))
130
+
131
+
132
+ def read_bounds(
133
+ path_or_buffer,
134
+ /,
135
+ layer=None,
136
+ skip_features=0,
137
+ max_features=None,
138
+ where=None,
139
+ bbox=None,
140
+ mask=None,
141
+ ):
142
+ """Read bounds of each feature.
143
+
144
+ This can be used to assist with spatial indexing and partitioning, in
145
+ order to avoid reading all features into memory. It is roughly 2-3x faster
146
+ than reading the full geometry and attributes of a dataset.
147
+
148
+ Parameters
149
+ ----------
150
+ path_or_buffer : str, pathlib.Path, bytes, or file-like
151
+ A dataset path or URI, raw buffer, or file-like object with a read method.
152
+ layer : int or str, optional (default: first layer)
153
+ If an integer is provided, it corresponds to the index of the layer
154
+ with the data source. If a string is provided, it must match the name
155
+ of the layer in the data source. Defaults to first layer in data source.
156
+ skip_features : int, optional (default: 0)
157
+ Number of features to skip from the beginning of the file before returning
158
+ features. Must be less than the total number of features in the file.
159
+ max_features : int, optional (default: None)
160
+ Number of features to read from the file. Must be less than the total
161
+ number of features in the file minus ``skip_features`` (if used).
162
+ where : str, optional (default: None)
163
+ Where clause to filter features in layer by attribute values. Uses a
164
+ restricted form of SQL WHERE clause, defined here:
165
+ http://ogdi.sourceforge.net/prop/6.2.CapabilitiesMetadata.html
166
+ Examples: ``"ISO_A3 = 'CAN'"``, ``"POP_EST > 10000000 AND POP_EST < 100000000"``
167
+ bbox : tuple of (xmin, ymin, xmax, ymax), optional (default: None)
168
+ If present, will be used to filter records whose geometry intersects this
169
+ box. This must be in the same CRS as the dataset. If GEOS is present
170
+ and used by GDAL, only geometries that intersect this bbox will be
171
+ returned; if GEOS is not available or not used by GDAL, all geometries
172
+ with bounding boxes that intersect this bbox will be returned.
173
+ mask : Shapely geometry, optional (default: None)
174
+ If present, will be used to filter records whose geometry intersects
175
+ this geometry. This must be in the same CRS as the dataset. If GEOS is
176
+ present and used by GDAL, only geometries that intersect this geometry
177
+ will be returned; if GEOS is not available or not used by GDAL, all
178
+ geometries with bounding boxes that intersect the bounding box of this
179
+ geometry will be returned. Requires Shapely >= 2.0.
180
+ Cannot be combined with ``bbox`` keyword.
181
+
182
+ Returns
183
+ -------
184
+ tuple of (fids, bounds)
185
+ fids are global IDs read from the FID field of the dataset
186
+ bounds are ndarray of shape(4, n) containing ``xmin``, ``ymin``, ``xmax``,
187
+ ``ymax``
188
+
189
+ """
190
+ return ogr_read_bounds(
191
+ get_vsi_path_or_buffer(path_or_buffer),
192
+ layer=layer,
193
+ skip_features=skip_features,
194
+ max_features=max_features or 0,
195
+ where=where,
196
+ bbox=bbox,
197
+ mask=_mask_to_wkb(mask),
198
+ )
199
+
200
+
201
+ def read_info(
202
+ path_or_buffer,
203
+ /,
204
+ layer=None,
205
+ encoding=None,
206
+ force_feature_count=False,
207
+ force_total_bounds=False,
208
+ **kwargs,
209
+ ):
210
+ """Read information about an OGR data source.
211
+
212
+ ``crs``, ``geometry`` and ``total_bounds`` will be ``None`` and ``features`` will be
213
+ 0 for a nonspatial layer.
214
+
215
+ ``features`` will be -1 if this is an expensive operation for this driver. You can
216
+ force it to be calculated using the ``force_feature_count`` parameter.
217
+
218
+ ``total_bounds`` is the 2-dimensional extent of all features within the dataset:
219
+ (xmin, ymin, xmax, ymax). It will be None if this is an expensive operation for this
220
+ driver or if the data source is nonspatial. You can force it to be calculated using
221
+ the ``force_total_bounds`` parameter.
222
+
223
+ ``fid_column`` is the name of the FID field in the data source, if the FID is
224
+ physically stored (e.g. in GPKG). If the FID is just a sequence, ``fid_column``
225
+ will be "" (e.g. ESRI Shapefile).
226
+
227
+ ``geometry_name`` is the name of the field where the main geometry is stored in the
228
+ data data source, if the field name can by customized (e.g. in GPKG). If no custom
229
+ name is supported, ``geometry_name`` will be "" (e.g. ESRI Shapefile).
230
+
231
+ ``encoding`` will be ``UTF-8`` if either the native encoding is likely to be
232
+ ``UTF-8`` or GDAL can automatically convert from the detected native encoding
233
+ to ``UTF-8``.
234
+
235
+ Parameters
236
+ ----------
237
+ path_or_buffer : str, pathlib.Path, bytes, or file-like
238
+ A dataset path or URI, raw buffer, or file-like object with a read method.
239
+ layer : str or int, optional
240
+ Name or index of layer in data source. Reads the first layer by default.
241
+ encoding : str, optional (default: None)
242
+ If present, will be used as the encoding for reading string values from
243
+ the data source, unless encoding can be inferred directly from the data
244
+ source.
245
+ force_feature_count : bool, optional (default: False)
246
+ True if the feature count should be computed even if it is expensive.
247
+ force_total_bounds : bool, optional (default: False)
248
+ True if the total bounds should be computed even if it is expensive.
249
+ **kwargs
250
+ Additional driver-specific dataset open options passed to OGR. Invalid
251
+ options will trigger a warning.
252
+
253
+ Returns
254
+ -------
255
+ dict
256
+ A dictionary with the following keys::
257
+
258
+ {
259
+ "layer_name": "<layer name>",
260
+ "crs": "<crs>",
261
+ "fields": <ndarray of field names>,
262
+ "dtypes": <ndarray of field dtypes>,
263
+ "ogr_types": <ndarray of OGR field types>,
264
+ "ogr_subtypes": <ndarray of OGR field subtypes>,
265
+ "encoding": "<encoding>",
266
+ "fid_column": "<fid column name or "">",
267
+ "geometry_name": "<geometry column name or "">",
268
+ "geometry_type": "<geometry type>",
269
+ "features": <feature count or -1>,
270
+ "total_bounds": <tuple with total bounds or None>,
271
+ "driver": "<driver>",
272
+ "capabilities": "<dict of driver capabilities>"
273
+ "dataset_metadata": "<dict of dataset metadata or None>"
274
+ "layer_metadata": "<dict of layer metadata or None>"
275
+ }
276
+
277
+ """
278
+ dataset_kwargs = _preprocess_options_key_value(kwargs) if kwargs else {}
279
+
280
+ return ogr_read_info(
281
+ get_vsi_path_or_buffer(path_or_buffer),
282
+ layer=layer,
283
+ encoding=encoding,
284
+ force_feature_count=force_feature_count,
285
+ force_total_bounds=force_total_bounds,
286
+ dataset_kwargs=dataset_kwargs,
287
+ )
288
+
289
+
290
+ def set_gdal_config_options(options):
291
+ """Set GDAL configuration options.
292
+
293
+ Options are listed here: https://trac.osgeo.org/gdal/wiki/ConfigOptions
294
+
295
+ No error is raised if invalid option names are provided.
296
+
297
+ These options are applied for an entire session rather than for individual
298
+ functions.
299
+
300
+ Parameters
301
+ ----------
302
+ options : dict
303
+ If present, provides a mapping of option name / value pairs for GDAL
304
+ configuration options. ``True`` / ``False`` are normalized to ``'ON'``
305
+ / ``'OFF'``. A value of ``None`` for a config option can be used to clear out a
306
+ previously set value.
307
+
308
+ """
309
+ _set_gdal_config_options(options)
310
+
311
+
312
+ def get_gdal_config_option(name):
313
+ """Get the value for a GDAL configuration option.
314
+
315
+ Parameters
316
+ ----------
317
+ name : str
318
+ name of the option to retrive
319
+
320
+ Returns
321
+ -------
322
+ value of the option or None if not set
323
+ ``'ON'`` / ``'OFF'`` are normalized to ``True`` / ``False``.
324
+
325
+ """
326
+ return _get_gdal_config_option(name)
327
+
328
+
329
+ def get_gdal_data_path():
330
+ """Get the path to the directory GDAL uses to read data files.
331
+
332
+ Returns
333
+ -------
334
+ str, or None if data directory was not found
335
+
336
+ """
337
+ return _get_gdal_data_path()
338
+
339
+
340
+ def vsi_listtree(path: str | Path, pattern: str | None = None):
341
+ """Recursively list the contents of a VSI directory.
342
+
343
+ An fnmatch pattern can be specified to filter the directories/files
344
+ returned.
345
+
346
+ Parameters
347
+ ----------
348
+ path : str or pathlib.Path
349
+ Path to the VSI directory to be listed.
350
+ pattern : str, optional
351
+ Pattern to filter results, in fnmatch format.
352
+
353
+ """
354
+ if isinstance(path, Path):
355
+ path = path.as_posix()
356
+
357
+ return ogr_vsi_listtree(path, pattern=pattern)
358
+
359
+
360
+ def vsi_rmtree(path: str | Path):
361
+ """Recursively remove VSI directory.
362
+
363
+ Parameters
364
+ ----------
365
+ path : str or pathlib.Path
366
+ path to the VSI directory to be removed.
367
+
368
+ """
369
+ if isinstance(path, Path):
370
+ path = path.as_posix()
371
+
372
+ ogr_vsi_rmtree(path)
373
+
374
+
375
+ def vsi_unlink(path: str | Path):
376
+ """Remove a VSI file.
377
+
378
+ Parameters
379
+ ----------
380
+ path : str or pathlib.Path
381
+ path to vsimem file to be removed
382
+
383
+ """
384
+ if isinstance(path, Path):
385
+ path = path.as_posix()
386
+
387
+ ogr_vsi_unlink(path)
pyogrio/errors.py ADDED
@@ -0,0 +1,25 @@
1
+ """Custom errors."""
2
+
3
+
4
+ class DataSourceError(RuntimeError):
5
+ """Errors relating to opening or closing an OGRDataSource (with >= 1 layers)."""
6
+
7
+
8
+ class DataLayerError(RuntimeError):
9
+ """Errors relating to working with a single OGRLayer."""
10
+
11
+
12
+ class CRSError(DataLayerError):
13
+ """Errors relating to getting or setting CRS values."""
14
+
15
+
16
+ class FeatureError(DataLayerError):
17
+ """Errors related to reading or writing a feature."""
18
+
19
+
20
+ class GeometryError(DataLayerError):
21
+ """Errors relating to getting or setting a geometry field."""
22
+
23
+
24
+ class FieldError(DataLayerError):
25
+ """Errors relating to getting or setting a non-geometry field."""
@@ -0,0 +1,19 @@
1
+ #----------------------------------------------------------------
2
+ # Generated CMake target import file for configuration "Release".
3
+ #----------------------------------------------------------------
4
+
5
+ # Commands may need to know the format version.
6
+ set(CMAKE_IMPORT_FILE_VERSION 1)
7
+
8
+ # Import target "GDAL::GDAL" for configuration "Release"
9
+ set_property(TARGET GDAL::GDAL APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
10
+ set_target_properties(GDAL::GDAL PROPERTIES
11
+ IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libgdal.37.3.11.4.dylib"
12
+ IMPORTED_SONAME_RELEASE "@rpath/libgdal.37.dylib"
13
+ )
14
+
15
+ list(APPEND _cmake_import_check_targets GDAL::GDAL )
16
+ list(APPEND _cmake_import_check_files_for_GDAL::GDAL "${_IMPORT_PREFIX}/lib/libgdal.37.3.11.4.dylib" )
17
+
18
+ # Commands beyond this point should not need to know the version.
19
+ set(CMAKE_IMPORT_FILE_VERSION)