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
@@ -0,0 +1,374 @@
1
+ import contextlib
2
+ import os
3
+ from pathlib import Path
4
+ from zipfile import ZIP_DEFLATED, ZipFile
5
+
6
+ import pyogrio
7
+ import pyogrio.raw
8
+ from pyogrio._compat import HAS_PYPROJ
9
+ from pyogrio.util import get_vsi_path_or_buffer, vsi_path
10
+
11
+ import pytest
12
+
13
+ try:
14
+ import geopandas # noqa: F401
15
+
16
+ has_geopandas = True
17
+ except ImportError:
18
+ has_geopandas = False
19
+
20
+
21
+ @contextlib.contextmanager
22
+ def change_cwd(path):
23
+ curdir = os.getcwd()
24
+ os.chdir(str(path))
25
+ try:
26
+ yield
27
+ finally:
28
+ os.chdir(curdir)
29
+
30
+
31
+ @pytest.mark.parametrize(
32
+ "path, expected",
33
+ [
34
+ # local file paths that should be passed through as is
35
+ ("data.gpkg", "data.gpkg"),
36
+ ("data.gpkg.zip", "data.gpkg.zip"),
37
+ ("data.shp.zip", "data.shp.zip"),
38
+ (Path("data.gpkg"), "data.gpkg"),
39
+ (Path("data.gpkg.zip"), "data.gpkg.zip"),
40
+ (Path("data.shp.zip"), "data.shp.zip"),
41
+ ("/home/user/data.gpkg", "/home/user/data.gpkg"),
42
+ ("/home/user/data.gpkg.zip", "/home/user/data.gpkg.zip"),
43
+ ("/home/user/data.shp.zip", "/home/user/data.shp.zip"),
44
+ (r"C:\User\Documents\data.gpkg", r"C:\User\Documents\data.gpkg"),
45
+ (r"C:\User\Documents\data.gpkg.zip", r"C:\User\Documents\data.gpkg.zip"),
46
+ (r"C:\User\Documents\data.shp.zip", r"C:\User\Documents\data.shp.zip"),
47
+ ("file:///home/user/data.gpkg", "/home/user/data.gpkg"),
48
+ ("file:///home/user/data.gpkg.zip", "/home/user/data.gpkg.zip"),
49
+ ("file:///home/user/data.shp.zip", "/home/user/data.shp.zip"),
50
+ ("/home/folder # with hash/data.gpkg", "/home/folder # with hash/data.gpkg"),
51
+ # cloud URIs
52
+ ("https://testing/data.gpkg", "/vsicurl/https://testing/data.gpkg"),
53
+ ("s3://testing/data.gpkg", "/vsis3/testing/data.gpkg"),
54
+ ("gs://testing/data.gpkg", "/vsigs/testing/data.gpkg"),
55
+ ("az://testing/data.gpkg", "/vsiaz/testing/data.gpkg"),
56
+ ("adl://testing/data.gpkg", "/vsiadls/testing/data.gpkg"),
57
+ ("adls://testing/data.gpkg", "/vsiadls/testing/data.gpkg"),
58
+ ("hdfs://testing/data.gpkg", "/vsihdfs/testing/data.gpkg"),
59
+ ("webhdfs://testing/data.gpkg", "/vsiwebhdfs/testing/data.gpkg"),
60
+ # archives
61
+ ("zip://data.zip", "/vsizip/data.zip"),
62
+ ("tar://data.tar", "/vsitar/data.tar"),
63
+ ("gzip://data.gz", "/vsigzip/data.gz"),
64
+ ("tar://./my.tar!my.geojson", "/vsitar/./my.tar/my.geojson"),
65
+ (
66
+ "zip://home/data/shapefile.zip!layer.shp",
67
+ "/vsizip/home/data/shapefile.zip/layer.shp",
68
+ ),
69
+ # combined schemes
70
+ ("zip+s3://testing/shapefile.zip", "/vsizip/vsis3/testing/shapefile.zip"),
71
+ (
72
+ "zip+https://s3.amazonaws.com/testing/shapefile.zip",
73
+ "/vsizip/vsicurl/https://s3.amazonaws.com/testing/shapefile.zip",
74
+ ),
75
+ # auto-prefix zip files
76
+ ("test.zip", "/vsizip/test.zip"),
77
+ ("/a/b/test.zip", "/vsizip//a/b/test.zip"),
78
+ ("a/b/test.zip", "/vsizip/a/b/test.zip"),
79
+ # archives using ! notation should be prefixed by vsizip
80
+ ("test.zip!item.shp", "/vsizip/test.zip/item.shp"),
81
+ ("test.zip!/a/b/item.shp", "/vsizip/test.zip/a/b/item.shp"),
82
+ ("test.zip!a/b/item.shp", "/vsizip/test.zip/a/b/item.shp"),
83
+ ("/vsizip/test.zip/a/b/item.shp", "/vsizip/test.zip/a/b/item.shp"),
84
+ ("zip:///test.zip/a/b/item.shp", "/vsizip//test.zip/a/b/item.shp"),
85
+ # auto-prefix remote zip files
86
+ (
87
+ "https://s3.amazonaws.com/testing/test.zip",
88
+ "/vsizip/vsicurl/https://s3.amazonaws.com/testing/test.zip",
89
+ ),
90
+ (
91
+ "https://s3.amazonaws.com/testing/test.zip!/a/b/item.shp",
92
+ "/vsizip/vsicurl/https://s3.amazonaws.com/testing/test.zip/a/b/item.shp",
93
+ ),
94
+ ("s3://testing/test.zip", "/vsizip/vsis3/testing/test.zip"),
95
+ (
96
+ "s3://testing/test.zip!a/b/item.shp",
97
+ "/vsizip/vsis3/testing/test.zip/a/b/item.shp",
98
+ ),
99
+ ("/vsimem/data.gpkg", "/vsimem/data.gpkg"),
100
+ (Path("/vsimem/data.gpkg"), "/vsimem/data.gpkg"),
101
+ ],
102
+ )
103
+ def test_vsi_path(path, expected):
104
+ assert vsi_path(path) == expected
105
+
106
+
107
+ def test_vsi_path_unknown():
108
+ # unrecognized URI gets passed through as is
109
+ assert vsi_path("s4://test/data.geojson") == "s4://test/data.geojson"
110
+
111
+
112
+ def test_vsi_handling_read_functions(naturalearth_lowres_vsi):
113
+ # test that all different read entry points have the path handling
114
+ # (a zip:// path would otherwise fail)
115
+ path, _ = naturalearth_lowres_vsi
116
+ path = "zip://" + str(path)
117
+
118
+ result = pyogrio.raw.read(path)
119
+ assert len(result[2]) == 177
120
+
121
+ result = pyogrio.read_info(path)
122
+ assert result["features"] == 177
123
+
124
+ result = pyogrio.read_bounds(path)
125
+ assert len(result[0]) == 177
126
+
127
+
128
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
129
+ def test_vsi_handling_read_dataframe(naturalearth_lowres_vsi):
130
+ path, _ = naturalearth_lowres_vsi
131
+ path = "zip://" + str(path)
132
+
133
+ result = pyogrio.read_dataframe(path)
134
+ assert len(result) == 177
135
+
136
+
137
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
138
+ def test_path_absolute(data_dir):
139
+ # pathlib path
140
+ path = data_dir / "naturalearth_lowres/naturalearth_lowres.shp"
141
+ df = pyogrio.read_dataframe(path)
142
+ assert len(df) == 177
143
+
144
+ # str path
145
+ df = pyogrio.read_dataframe(str(path))
146
+ assert len(df) == 177
147
+
148
+
149
+ def test_path_relative(data_dir):
150
+ path = "naturalearth_lowres/naturalearth_lowres.shp"
151
+
152
+ with change_cwd(data_dir):
153
+ result = pyogrio.raw.read(path)
154
+ assert len(result[2]) == 177
155
+
156
+ result = pyogrio.read_info(path)
157
+ assert result["features"] == 177
158
+
159
+ result = pyogrio.read_bounds(path)
160
+ assert len(result[0]) == 177
161
+
162
+
163
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
164
+ def test_path_relative_dataframe(data_dir):
165
+ with change_cwd(data_dir):
166
+ df = pyogrio.read_dataframe("naturalearth_lowres/naturalearth_lowres.shp")
167
+ assert len(df) == 177
168
+
169
+
170
+ def test_uri_local_file(data_dir):
171
+ path = "file://" + str(data_dir / "naturalearth_lowres/naturalearth_lowres.shp")
172
+ result = pyogrio.raw.read(path)
173
+ assert len(result[2]) == 177
174
+
175
+ result = pyogrio.read_info(path)
176
+ assert result["features"] == 177
177
+
178
+ result = pyogrio.read_bounds(path)
179
+ assert len(result[0]) == 177
180
+
181
+
182
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
183
+ def test_uri_local_file_dataframe(data_dir):
184
+ uri = "file://" + str(data_dir / "naturalearth_lowres/naturalearth_lowres.shp")
185
+ df = pyogrio.read_dataframe(uri)
186
+ assert len(df) == 177
187
+
188
+
189
+ def test_zip_path(naturalearth_lowres_vsi):
190
+ path, path_vsi = naturalearth_lowres_vsi
191
+ path_zip = "zip://" + str(path)
192
+
193
+ # absolute zip path
194
+ result = pyogrio.raw.read(path_zip)
195
+ assert len(result[2]) == 177
196
+
197
+ result = pyogrio.read_info(path_zip)
198
+ assert result["features"] == 177
199
+
200
+ result = pyogrio.read_bounds(path_zip)
201
+ assert len(result[0]) == 177
202
+
203
+ # absolute vsizip path
204
+ result = pyogrio.raw.read(path_vsi)
205
+ assert len(result[2]) == 177
206
+
207
+ result = pyogrio.read_info(path_vsi)
208
+ assert result["features"] == 177
209
+
210
+ result = pyogrio.read_bounds(path_vsi)
211
+ assert len(result[0]) == 177
212
+
213
+ # relative zip path
214
+ relative_path = "zip://" + path.name
215
+ with change_cwd(path.parent):
216
+ result = pyogrio.raw.read(relative_path)
217
+ assert len(result[2]) == 177
218
+
219
+ result = pyogrio.read_info(relative_path)
220
+ assert result["features"] == 177
221
+
222
+ result = pyogrio.read_bounds(relative_path)
223
+ assert len(result[0]) == 177
224
+
225
+
226
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
227
+ def test_zip_path_dataframe(naturalearth_lowres_vsi):
228
+ path, path_vsi = naturalearth_lowres_vsi
229
+ path_zip = "zip://" + str(path)
230
+
231
+ # absolute zip path
232
+ df = pyogrio.read_dataframe(path_zip)
233
+ assert len(df) == 177
234
+
235
+ # absolute vsizip path
236
+ df = pyogrio.read_dataframe(path_vsi)
237
+ assert len(df) == 177
238
+
239
+ # relative zip path
240
+ with change_cwd(path.parent):
241
+ df = pyogrio.read_dataframe("zip://" + path.name)
242
+ assert len(df) == 177
243
+
244
+
245
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
246
+ def test_detect_zip_path(tmp_path, naturalearth_lowres):
247
+ # create a zipfile with 2 shapefiles in a set of subdirectories
248
+ df = pyogrio.read_dataframe(naturalearth_lowres, where="iso_a3 in ('CAN', 'PER')")
249
+ pyogrio.write_dataframe(df.loc[df.iso_a3 == "CAN"], tmp_path / "test1.shp")
250
+ pyogrio.write_dataframe(df.loc[df.iso_a3 == "PER"], tmp_path / "test2.shp")
251
+
252
+ path = tmp_path / "test.zip"
253
+ with ZipFile(path, mode="w", compression=ZIP_DEFLATED, compresslevel=5) as out:
254
+ for ext in ["dbf", "prj", "shp", "shx"]:
255
+ if not HAS_PYPROJ and ext == "prj":
256
+ continue
257
+
258
+ filename = f"test1.{ext}"
259
+ out.write(tmp_path / filename, filename)
260
+
261
+ filename = f"test2.{ext}"
262
+ out.write(tmp_path / filename, f"/a/b/{filename}")
263
+
264
+ # defaults to the first shapefile found, at lowest subdirectory
265
+ df = pyogrio.read_dataframe(path)
266
+ assert df.iso_a3[0] == "CAN"
267
+
268
+ # selecting a shapefile from within the zip requires "!"" archive specifier
269
+ df = pyogrio.read_dataframe(f"{path}!test1.shp")
270
+ assert df.iso_a3[0] == "CAN"
271
+
272
+ df = pyogrio.read_dataframe(f"{path}!/a/b/test2.shp")
273
+ assert df.iso_a3[0] == "PER"
274
+
275
+ # specifying zip:// scheme should also work
276
+ df = pyogrio.read_dataframe(f"zip://{path}!/a/b/test2.shp")
277
+ assert df.iso_a3[0] == "PER"
278
+
279
+ # specifying /vsizip/ should also work but path must already be in GDAL ready
280
+ # format without the "!"" archive specifier
281
+ df = pyogrio.read_dataframe(f"/vsizip/{path}/a/b/test2.shp")
282
+ assert df.iso_a3[0] == "PER"
283
+
284
+
285
+ @pytest.mark.network
286
+ def test_url():
287
+ url = "https://raw.githubusercontent.com/geopandas/pyogrio/main/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shp"
288
+
289
+ result = pyogrio.raw.read(url)
290
+ assert len(result[2]) == 177
291
+
292
+ result = pyogrio.read_info(url)
293
+ assert result["features"] == 177
294
+
295
+ result = pyogrio.read_bounds(url)
296
+ assert len(result[0]) == 177
297
+
298
+
299
+ @pytest.mark.network
300
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
301
+ def test_url_dataframe():
302
+ url = "https://raw.githubusercontent.com/geopandas/pyogrio/main/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shp"
303
+
304
+ assert len(pyogrio.read_dataframe(url)) == 177
305
+
306
+
307
+ @pytest.mark.network
308
+ def test_url_with_zip():
309
+ url = "zip+https://s3.amazonaws.com/fiona-testing/coutwildrnp.zip"
310
+
311
+ result = pyogrio.raw.read(url)
312
+ assert len(result[2]) == 67
313
+
314
+ result = pyogrio.read_info(url)
315
+ assert result["features"] == 67
316
+
317
+ result = pyogrio.read_bounds(url)
318
+ assert len(result[0]) == 67
319
+
320
+
321
+ @pytest.mark.network
322
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
323
+ def test_url_with_zip_dataframe():
324
+ url = "zip+https://s3.amazonaws.com/fiona-testing/coutwildrnp.zip"
325
+ df = pyogrio.read_dataframe(url)
326
+ assert len(df) == 67
327
+
328
+
329
+ @pytest.fixture
330
+ def aws_env_setup(monkeypatch):
331
+ monkeypatch.setenv("AWS_NO_SIGN_REQUEST", "YES")
332
+
333
+
334
+ @pytest.mark.network
335
+ def test_uri_s3(aws_env_setup):
336
+ url = "zip+s3://fiona-testing/coutwildrnp.zip"
337
+
338
+ result = pyogrio.raw.read(url)
339
+ assert len(result[2]) == 67
340
+
341
+ result = pyogrio.read_info(url)
342
+ assert result["features"] == 67
343
+
344
+ result = pyogrio.read_bounds(url)
345
+ assert len(result[0]) == 67
346
+
347
+
348
+ @pytest.mark.network
349
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
350
+ def test_uri_s3_dataframe(aws_env_setup):
351
+ df = pyogrio.read_dataframe("zip+s3://fiona-testing/coutwildrnp.zip")
352
+ assert len(df) == 67
353
+
354
+
355
+ @pytest.mark.parametrize(
356
+ "path, expected",
357
+ [
358
+ (Path("/tmp/test.gpkg"), str(Path("/tmp/test.gpkg"))),
359
+ (Path("/vsimem/test.gpkg"), "/vsimem/test.gpkg"),
360
+ ],
361
+ )
362
+ def test_get_vsi_path_or_buffer_obj_to_string(path, expected):
363
+ """Verify that get_vsi_path_or_buffer retains forward slashes in /vsimem paths.
364
+
365
+ The /vsimem paths should keep forward slashes for GDAL to recognize them as such.
366
+ However, on Windows systems, forward slashes are by default replaced by backslashes,
367
+ so this test verifies that this doesn't happen for /vsimem paths.
368
+ """
369
+ assert get_vsi_path_or_buffer(path) == expected
370
+
371
+
372
+ def test_get_vsi_path_or_buffer_fixtures_to_string(tmp_path):
373
+ path = tmp_path / "test.gpkg"
374
+ assert get_vsi_path_or_buffer(path) == str(path)