pyogrio 0.8.0__cp312-cp312-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 (238) hide show
  1. pyogrio/__init__.py +48 -0
  2. pyogrio/_compat.py +41 -0
  3. pyogrio/_env.py +61 -0
  4. pyogrio/_err.cpython-312-aarch64-linux-gnu.so +0 -0
  5. pyogrio/_err.pxd +4 -0
  6. pyogrio/_err.pyx +250 -0
  7. pyogrio/_geometry.cpython-312-aarch64-linux-gnu.so +0 -0
  8. pyogrio/_geometry.pxd +4 -0
  9. pyogrio/_geometry.pyx +129 -0
  10. pyogrio/_io.cpython-312-aarch64-linux-gnu.so +0 -0
  11. pyogrio/_io.pxd +0 -0
  12. pyogrio/_io.pyx +2738 -0
  13. pyogrio/_ogr.cpython-312-aarch64-linux-gnu.so +0 -0
  14. pyogrio/_ogr.pxd +441 -0
  15. pyogrio/_ogr.pyx +346 -0
  16. pyogrio/_version.py +21 -0
  17. pyogrio/_vsi.cpython-312-aarch64-linux-gnu.so +0 -0
  18. pyogrio/_vsi.pxd +4 -0
  19. pyogrio/_vsi.pyx +140 -0
  20. pyogrio/arrow_bridge.h +115 -0
  21. pyogrio/core.py +320 -0
  22. pyogrio/errors.py +32 -0
  23. pyogrio/gdal_data/GDAL-targets-release.cmake +19 -0
  24. pyogrio/gdal_data/GDAL-targets.cmake +105 -0
  25. pyogrio/gdal_data/GDALConfig.cmake +25 -0
  26. pyogrio/gdal_data/GDALConfigVersion.cmake +85 -0
  27. pyogrio/gdal_data/GDALLogoBW.svg +138 -0
  28. pyogrio/gdal_data/GDALLogoColor.svg +126 -0
  29. pyogrio/gdal_data/GDALLogoGS.svg +126 -0
  30. pyogrio/gdal_data/LICENSE.TXT +467 -0
  31. pyogrio/gdal_data/bag_template.xml +201 -0
  32. pyogrio/gdal_data/copyright +467 -0
  33. pyogrio/gdal_data/cubewerx_extra.wkt +48 -0
  34. pyogrio/gdal_data/default.rsc +0 -0
  35. pyogrio/gdal_data/ecw_cs.wkt +1453 -0
  36. pyogrio/gdal_data/eedaconf.json +23 -0
  37. pyogrio/gdal_data/epsg.wkt +1 -0
  38. pyogrio/gdal_data/esri_StatePlane_extra.wkt +631 -0
  39. pyogrio/gdal_data/gdalicon.png +0 -0
  40. pyogrio/gdal_data/gdalinfo_output.schema.json +346 -0
  41. pyogrio/gdal_data/gdalmdiminfo_output.schema.json +321 -0
  42. pyogrio/gdal_data/gdalvrt.xsd +772 -0
  43. pyogrio/gdal_data/gfs.xsd +246 -0
  44. pyogrio/gdal_data/gml_registry.xml +117 -0
  45. pyogrio/gdal_data/gml_registry.xsd +66 -0
  46. pyogrio/gdal_data/gmlasconf.xml +169 -0
  47. pyogrio/gdal_data/gmlasconf.xsd +1066 -0
  48. pyogrio/gdal_data/grib2_center.csv +251 -0
  49. pyogrio/gdal_data/grib2_process.csv +102 -0
  50. pyogrio/gdal_data/grib2_subcenter.csv +63 -0
  51. pyogrio/gdal_data/grib2_table_4_2_0_0.csv +261 -0
  52. pyogrio/gdal_data/grib2_table_4_2_0_1.csv +261 -0
  53. pyogrio/gdal_data/grib2_table_4_2_0_13.csv +261 -0
  54. pyogrio/gdal_data/grib2_table_4_2_0_14.csv +261 -0
  55. pyogrio/gdal_data/grib2_table_4_2_0_15.csv +261 -0
  56. pyogrio/gdal_data/grib2_table_4_2_0_16.csv +261 -0
  57. pyogrio/gdal_data/grib2_table_4_2_0_17.csv +11 -0
  58. pyogrio/gdal_data/grib2_table_4_2_0_18.csv +261 -0
  59. pyogrio/gdal_data/grib2_table_4_2_0_19.csv +261 -0
  60. pyogrio/gdal_data/grib2_table_4_2_0_190.csv +261 -0
  61. pyogrio/gdal_data/grib2_table_4_2_0_191.csv +261 -0
  62. pyogrio/gdal_data/grib2_table_4_2_0_2.csv +261 -0
  63. pyogrio/gdal_data/grib2_table_4_2_0_20.csv +261 -0
  64. pyogrio/gdal_data/grib2_table_4_2_0_21.csv +261 -0
  65. pyogrio/gdal_data/grib2_table_4_2_0_3.csv +261 -0
  66. pyogrio/gdal_data/grib2_table_4_2_0_4.csv +261 -0
  67. pyogrio/gdal_data/grib2_table_4_2_0_5.csv +261 -0
  68. pyogrio/gdal_data/grib2_table_4_2_0_6.csv +261 -0
  69. pyogrio/gdal_data/grib2_table_4_2_0_7.csv +261 -0
  70. pyogrio/gdal_data/grib2_table_4_2_10_0.csv +261 -0
  71. pyogrio/gdal_data/grib2_table_4_2_10_1.csv +261 -0
  72. pyogrio/gdal_data/grib2_table_4_2_10_191.csv +261 -0
  73. pyogrio/gdal_data/grib2_table_4_2_10_2.csv +261 -0
  74. pyogrio/gdal_data/grib2_table_4_2_10_3.csv +261 -0
  75. pyogrio/gdal_data/grib2_table_4_2_10_4.csv +261 -0
  76. pyogrio/gdal_data/grib2_table_4_2_1_0.csv +261 -0
  77. pyogrio/gdal_data/grib2_table_4_2_1_1.csv +261 -0
  78. pyogrio/gdal_data/grib2_table_4_2_1_2.csv +261 -0
  79. pyogrio/gdal_data/grib2_table_4_2_20_0.csv +261 -0
  80. pyogrio/gdal_data/grib2_table_4_2_20_1.csv +261 -0
  81. pyogrio/gdal_data/grib2_table_4_2_20_2.csv +261 -0
  82. pyogrio/gdal_data/grib2_table_4_2_2_0.csv +261 -0
  83. pyogrio/gdal_data/grib2_table_4_2_2_3.csv +261 -0
  84. pyogrio/gdal_data/grib2_table_4_2_2_4.csv +261 -0
  85. pyogrio/gdal_data/grib2_table_4_2_2_5.csv +261 -0
  86. pyogrio/gdal_data/grib2_table_4_2_2_6.csv +261 -0
  87. pyogrio/gdal_data/grib2_table_4_2_3_0.csv +261 -0
  88. pyogrio/gdal_data/grib2_table_4_2_3_1.csv +261 -0
  89. pyogrio/gdal_data/grib2_table_4_2_3_2.csv +28 -0
  90. pyogrio/gdal_data/grib2_table_4_2_3_3.csv +8 -0
  91. pyogrio/gdal_data/grib2_table_4_2_3_4.csv +14 -0
  92. pyogrio/gdal_data/grib2_table_4_2_3_5.csv +11 -0
  93. pyogrio/gdal_data/grib2_table_4_2_3_6.csv +11 -0
  94. pyogrio/gdal_data/grib2_table_4_2_4_0.csv +261 -0
  95. pyogrio/gdal_data/grib2_table_4_2_4_1.csv +261 -0
  96. pyogrio/gdal_data/grib2_table_4_2_4_10.csv +261 -0
  97. pyogrio/gdal_data/grib2_table_4_2_4_2.csv +261 -0
  98. pyogrio/gdal_data/grib2_table_4_2_4_3.csv +261 -0
  99. pyogrio/gdal_data/grib2_table_4_2_4_4.csv +261 -0
  100. pyogrio/gdal_data/grib2_table_4_2_4_5.csv +261 -0
  101. pyogrio/gdal_data/grib2_table_4_2_4_6.csv +261 -0
  102. pyogrio/gdal_data/grib2_table_4_2_4_7.csv +261 -0
  103. pyogrio/gdal_data/grib2_table_4_2_4_8.csv +261 -0
  104. pyogrio/gdal_data/grib2_table_4_2_4_9.csv +261 -0
  105. pyogrio/gdal_data/grib2_table_4_2_local_Canada.csv +5 -0
  106. pyogrio/gdal_data/grib2_table_4_2_local_HPC.csv +2 -0
  107. pyogrio/gdal_data/grib2_table_4_2_local_MRMS.csv +175 -0
  108. pyogrio/gdal_data/grib2_table_4_2_local_NCEP.csv +401 -0
  109. pyogrio/gdal_data/grib2_table_4_2_local_NDFD.csv +38 -0
  110. pyogrio/gdal_data/grib2_table_4_2_local_index.csv +7 -0
  111. pyogrio/gdal_data/grib2_table_4_5.csv +261 -0
  112. pyogrio/gdal_data/grib2_table_versions.csv +3 -0
  113. pyogrio/gdal_data/gt_datum.csv +229 -0
  114. pyogrio/gdal_data/gt_ellips.csv +24 -0
  115. pyogrio/gdal_data/header.dxf +1124 -0
  116. pyogrio/gdal_data/inspire_cp_BasicPropertyUnit.gfs +57 -0
  117. pyogrio/gdal_data/inspire_cp_CadastralBoundary.gfs +60 -0
  118. pyogrio/gdal_data/inspire_cp_CadastralParcel.gfs +81 -0
  119. pyogrio/gdal_data/inspire_cp_CadastralZoning.gfs +161 -0
  120. pyogrio/gdal_data/jpfgdgml_AdmArea.gfs +59 -0
  121. pyogrio/gdal_data/jpfgdgml_AdmBdry.gfs +49 -0
  122. pyogrio/gdal_data/jpfgdgml_AdmPt.gfs +59 -0
  123. pyogrio/gdal_data/jpfgdgml_BldA.gfs +54 -0
  124. pyogrio/gdal_data/jpfgdgml_BldL.gfs +54 -0
  125. pyogrio/gdal_data/jpfgdgml_Cntr.gfs +54 -0
  126. pyogrio/gdal_data/jpfgdgml_CommBdry.gfs +49 -0
  127. pyogrio/gdal_data/jpfgdgml_CommPt.gfs +59 -0
  128. pyogrio/gdal_data/jpfgdgml_Cstline.gfs +54 -0
  129. pyogrio/gdal_data/jpfgdgml_ElevPt.gfs +54 -0
  130. pyogrio/gdal_data/jpfgdgml_GCP.gfs +94 -0
  131. pyogrio/gdal_data/jpfgdgml_LeveeEdge.gfs +49 -0
  132. pyogrio/gdal_data/jpfgdgml_RailCL.gfs +54 -0
  133. pyogrio/gdal_data/jpfgdgml_RdASL.gfs +44 -0
  134. pyogrio/gdal_data/jpfgdgml_RdArea.gfs +54 -0
  135. pyogrio/gdal_data/jpfgdgml_RdCompt.gfs +59 -0
  136. pyogrio/gdal_data/jpfgdgml_RdEdg.gfs +59 -0
  137. pyogrio/gdal_data/jpfgdgml_RdMgtBdry.gfs +49 -0
  138. pyogrio/gdal_data/jpfgdgml_RdSgmtA.gfs +59 -0
  139. pyogrio/gdal_data/jpfgdgml_RvrMgtBdry.gfs +49 -0
  140. pyogrio/gdal_data/jpfgdgml_SBAPt.gfs +49 -0
  141. pyogrio/gdal_data/jpfgdgml_SBArea.gfs +54 -0
  142. pyogrio/gdal_data/jpfgdgml_SBBdry.gfs +44 -0
  143. pyogrio/gdal_data/jpfgdgml_WA.gfs +54 -0
  144. pyogrio/gdal_data/jpfgdgml_WL.gfs +54 -0
  145. pyogrio/gdal_data/jpfgdgml_WStrA.gfs +54 -0
  146. pyogrio/gdal_data/jpfgdgml_WStrL.gfs +54 -0
  147. pyogrio/gdal_data/netcdf_config.xsd +143 -0
  148. pyogrio/gdal_data/nitf_spec.xml +3306 -0
  149. pyogrio/gdal_data/nitf_spec.xsd +189 -0
  150. pyogrio/gdal_data/ogrinfo_output.schema.json +505 -0
  151. pyogrio/gdal_data/ogrvrt.xsd +543 -0
  152. pyogrio/gdal_data/osmconf.ini +132 -0
  153. pyogrio/gdal_data/ozi_datum.csv +131 -0
  154. pyogrio/gdal_data/ozi_ellips.csv +35 -0
  155. pyogrio/gdal_data/pci_datum.txt +463 -0
  156. pyogrio/gdal_data/pci_ellips.txt +77 -0
  157. pyogrio/gdal_data/pdfcomposition.xsd +721 -0
  158. pyogrio/gdal_data/pds4_template.xml +65 -0
  159. pyogrio/gdal_data/plscenesconf.json +1985 -0
  160. pyogrio/gdal_data/ruian_vf_ob_v1.gfs +1455 -0
  161. pyogrio/gdal_data/ruian_vf_st_uvoh_v1.gfs +86 -0
  162. pyogrio/gdal_data/ruian_vf_st_v1.gfs +1489 -0
  163. pyogrio/gdal_data/ruian_vf_v1.gfs +2126 -0
  164. pyogrio/gdal_data/s57agencies.csv +249 -0
  165. pyogrio/gdal_data/s57attributes.csv +484 -0
  166. pyogrio/gdal_data/s57expectedinput.csv +1008 -0
  167. pyogrio/gdal_data/s57objectclasses.csv +287 -0
  168. pyogrio/gdal_data/seed_2d.dgn +0 -0
  169. pyogrio/gdal_data/seed_3d.dgn +0 -0
  170. pyogrio/gdal_data/stateplane.csv +259 -0
  171. pyogrio/gdal_data/template_tiles.mapml +28 -0
  172. pyogrio/gdal_data/tms_LINZAntarticaMapTileGrid.json +190 -0
  173. pyogrio/gdal_data/tms_MapML_APSTILE.json +268 -0
  174. pyogrio/gdal_data/tms_MapML_CBMTILE.json +346 -0
  175. pyogrio/gdal_data/tms_NZTM2000.json +243 -0
  176. pyogrio/gdal_data/trailer.dxf +434 -0
  177. pyogrio/gdal_data/usage +4 -0
  178. pyogrio/gdal_data/vcpkg-cmake-wrapper.cmake +23 -0
  179. pyogrio/gdal_data/vcpkg.spdx.json +264 -0
  180. pyogrio/gdal_data/vcpkg_abi_info.txt +41 -0
  181. pyogrio/gdal_data/vdv452.xml +367 -0
  182. pyogrio/gdal_data/vdv452.xsd +63 -0
  183. pyogrio/gdal_data/vicar.json +164 -0
  184. pyogrio/geopandas.py +666 -0
  185. pyogrio/proj_data/CH +22 -0
  186. pyogrio/proj_data/GL27 +23 -0
  187. pyogrio/proj_data/ITRF2000 +24 -0
  188. pyogrio/proj_data/ITRF2008 +94 -0
  189. pyogrio/proj_data/ITRF2014 +55 -0
  190. pyogrio/proj_data/copyright +34 -0
  191. pyogrio/proj_data/deformation_model.schema.json +582 -0
  192. pyogrio/proj_data/nad.lst +142 -0
  193. pyogrio/proj_data/nad27 +810 -0
  194. pyogrio/proj_data/nad83 +745 -0
  195. pyogrio/proj_data/other.extra +53 -0
  196. pyogrio/proj_data/proj-config-version.cmake +44 -0
  197. pyogrio/proj_data/proj-config.cmake +79 -0
  198. pyogrio/proj_data/proj-targets-release.cmake +19 -0
  199. pyogrio/proj_data/proj-targets.cmake +107 -0
  200. pyogrio/proj_data/proj.db +0 -0
  201. pyogrio/proj_data/proj.ini +51 -0
  202. pyogrio/proj_data/proj4-targets-release.cmake +19 -0
  203. pyogrio/proj_data/proj4-targets.cmake +107 -0
  204. pyogrio/proj_data/projjson.schema.json +1174 -0
  205. pyogrio/proj_data/triangulation.schema.json +214 -0
  206. pyogrio/proj_data/usage +4 -0
  207. pyogrio/proj_data/vcpkg.spdx.json +198 -0
  208. pyogrio/proj_data/vcpkg_abi_info.txt +27 -0
  209. pyogrio/proj_data/world +214 -0
  210. pyogrio/raw.py +871 -0
  211. pyogrio/tests/__init__.py +0 -0
  212. pyogrio/tests/conftest.py +204 -0
  213. pyogrio/tests/fixtures/README.md +89 -0
  214. pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.cpg +1 -0
  215. pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.dbf +0 -0
  216. pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.prj +1 -0
  217. pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shp +0 -0
  218. pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shx +0 -0
  219. pyogrio/tests/fixtures/sample.osm.pbf +0 -0
  220. pyogrio/tests/fixtures/test_datetime.geojson +7 -0
  221. pyogrio/tests/fixtures/test_datetime_tz.geojson +8 -0
  222. pyogrio/tests/fixtures/test_fgdb.gdb.zip +0 -0
  223. pyogrio/tests/fixtures/test_gpkg_nulls.gpkg +0 -0
  224. pyogrio/tests/fixtures/test_multisurface.gpkg +0 -0
  225. pyogrio/tests/fixtures/test_nested.geojson +18 -0
  226. pyogrio/tests/fixtures/test_ogr_types_list.geojson +12 -0
  227. pyogrio/tests/test_arrow.py +1041 -0
  228. pyogrio/tests/test_core.py +588 -0
  229. pyogrio/tests/test_geopandas_io.py +2069 -0
  230. pyogrio/tests/test_path.py +351 -0
  231. pyogrio/tests/test_raw_io.py +1404 -0
  232. pyogrio/util.py +223 -0
  233. pyogrio-0.8.0.dist-info/LICENSE +21 -0
  234. pyogrio-0.8.0.dist-info/METADATA +100 -0
  235. pyogrio-0.8.0.dist-info/RECORD +238 -0
  236. pyogrio-0.8.0.dist-info/WHEEL +5 -0
  237. pyogrio-0.8.0.dist-info/top_level.txt +1 -0
  238. pyogrio.libs/libgdal-b2fb2022.so.34.3.8.5 +0 -0
@@ -0,0 +1,351 @@
1
+ import os
2
+ from pathlib import Path
3
+ import contextlib
4
+ from zipfile import ZipFile, ZIP_DEFLATED
5
+
6
+ import pytest
7
+
8
+ import pyogrio
9
+ import pyogrio.raw
10
+ from pyogrio.util import vsi_path, get_vsi_path_or_buffer
11
+
12
+ try:
13
+ import geopandas # NOQA
14
+
15
+ has_geopandas = True
16
+ except ImportError:
17
+ has_geopandas = False
18
+
19
+
20
+ @contextlib.contextmanager
21
+ def change_cwd(path):
22
+ curdir = os.getcwd()
23
+ os.chdir(str(path))
24
+ try:
25
+ yield
26
+ finally:
27
+ os.chdir(curdir)
28
+
29
+
30
+ @pytest.mark.parametrize(
31
+ "path, expected",
32
+ [
33
+ # local file paths that should be passed through as is
34
+ ("data.gpkg", "data.gpkg"),
35
+ ("/home/user/data.gpkg", "/home/user/data.gpkg"),
36
+ (r"C:\User\Documents\data.gpkg", r"C:\User\Documents\data.gpkg"),
37
+ ("file:///home/user/data.gpkg", "/home/user/data.gpkg"),
38
+ # cloud URIs
39
+ ("https://testing/data.gpkg", "/vsicurl/https://testing/data.gpkg"),
40
+ ("s3://testing/data.gpkg", "/vsis3/testing/data.gpkg"),
41
+ ("gs://testing/data.gpkg", "/vsigs/testing/data.gpkg"),
42
+ ("az://testing/data.gpkg", "/vsiaz/testing/data.gpkg"),
43
+ ("adl://testing/data.gpkg", "/vsiadls/testing/data.gpkg"),
44
+ ("adls://testing/data.gpkg", "/vsiadls/testing/data.gpkg"),
45
+ ("hdfs://testing/data.gpkg", "/vsihdfs/testing/data.gpkg"),
46
+ ("webhdfs://testing/data.gpkg", "/vsiwebhdfs/testing/data.gpkg"),
47
+ # archives
48
+ ("zip://data.zip", "/vsizip/data.zip"),
49
+ ("tar://data.tar", "/vsitar/data.tar"),
50
+ ("gzip://data.gz", "/vsigzip/data.gz"),
51
+ ("tar://./my.tar!my.geojson", "/vsitar/./my.tar/my.geojson"),
52
+ (
53
+ "zip://home/data/shapefile.zip!layer.shp",
54
+ "/vsizip/home/data/shapefile.zip/layer.shp",
55
+ ),
56
+ # combined schemes
57
+ ("zip+s3://testing/shapefile.zip", "/vsizip/vsis3/testing/shapefile.zip"),
58
+ (
59
+ "zip+https://s3.amazonaws.com/testing/shapefile.zip",
60
+ "/vsizip/vsicurl/https://s3.amazonaws.com/testing/shapefile.zip",
61
+ ),
62
+ # auto-prefix zip files
63
+ ("test.zip", "/vsizip/test.zip"),
64
+ ("/a/b/test.zip", "/vsizip//a/b/test.zip"),
65
+ ("a/b/test.zip", "/vsizip/a/b/test.zip"),
66
+ # archives using ! notation should be prefixed by vsizip
67
+ ("test.zip!item.shp", "/vsizip/test.zip/item.shp"),
68
+ ("test.zip!/a/b/item.shp", "/vsizip/test.zip/a/b/item.shp"),
69
+ ("test.zip!a/b/item.shp", "/vsizip/test.zip/a/b/item.shp"),
70
+ ("/vsizip/test.zip/a/b/item.shp", "/vsizip/test.zip/a/b/item.shp"),
71
+ ("zip:///test.zip/a/b/item.shp", "/vsizip//test.zip/a/b/item.shp"),
72
+ # auto-prefix remote zip files
73
+ (
74
+ "https://s3.amazonaws.com/testing/test.zip",
75
+ "/vsizip/vsicurl/https://s3.amazonaws.com/testing/test.zip",
76
+ ),
77
+ (
78
+ "https://s3.amazonaws.com/testing/test.zip!/a/b/item.shp",
79
+ "/vsizip/vsicurl/https://s3.amazonaws.com/testing/test.zip/a/b/item.shp",
80
+ ),
81
+ ("s3://testing/test.zip", "/vsizip/vsis3/testing/test.zip"),
82
+ (
83
+ "s3://testing/test.zip!a/b/item.shp",
84
+ "/vsizip/vsis3/testing/test.zip/a/b/item.shp",
85
+ ),
86
+ ],
87
+ )
88
+ def test_vsi_path(path, expected):
89
+ assert vsi_path(path) == expected
90
+
91
+
92
+ def test_vsi_path_unknown():
93
+ # unrecognized URI gets passed through as is
94
+ assert vsi_path("s4://test/data.geojson") == "s4://test/data.geojson"
95
+
96
+
97
+ def test_vsi_handling_read_functions(naturalearth_lowres_vsi):
98
+ # test that all different read entry points have the path handling
99
+ # (a zip:// path would otherwise fail)
100
+ path, _ = naturalearth_lowres_vsi
101
+ path = "zip://" + str(path)
102
+
103
+ result = pyogrio.raw.read(path)
104
+ assert len(result[2]) == 177
105
+
106
+ result = pyogrio.read_info(path)
107
+ assert result["features"] == 177
108
+
109
+ result = pyogrio.read_bounds(path)
110
+ assert len(result[0]) == 177
111
+
112
+
113
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
114
+ def test_vsi_handling_read_dataframe(naturalearth_lowres_vsi):
115
+ path, _ = naturalearth_lowres_vsi
116
+ path = "zip://" + str(path)
117
+
118
+ result = pyogrio.read_dataframe(path)
119
+ assert len(result) == 177
120
+
121
+
122
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
123
+ def test_path_absolute(data_dir):
124
+ # pathlib path
125
+ path = data_dir / "naturalearth_lowres/naturalearth_lowres.shp"
126
+ df = pyogrio.read_dataframe(path)
127
+ assert len(df) == 177
128
+
129
+ # str path
130
+ df = pyogrio.read_dataframe(str(path))
131
+ assert len(df) == 177
132
+
133
+
134
+ def test_path_relative(data_dir):
135
+ path = "naturalearth_lowres/naturalearth_lowres.shp"
136
+
137
+ with change_cwd(data_dir):
138
+ result = pyogrio.raw.read(path)
139
+ assert len(result[2]) == 177
140
+
141
+ result = pyogrio.read_info(path)
142
+ assert result["features"] == 177
143
+
144
+ result = pyogrio.read_bounds(path)
145
+ assert len(result[0]) == 177
146
+
147
+
148
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
149
+ def test_path_relative_dataframe(data_dir):
150
+ with change_cwd(data_dir):
151
+ df = pyogrio.read_dataframe("naturalearth_lowres/naturalearth_lowres.shp")
152
+ assert len(df) == 177
153
+
154
+
155
+ def test_uri_local_file(data_dir):
156
+ path = "file://" + str(data_dir / "naturalearth_lowres/naturalearth_lowres.shp")
157
+ result = pyogrio.raw.read(path)
158
+ assert len(result[2]) == 177
159
+
160
+ result = pyogrio.read_info(path)
161
+ assert result["features"] == 177
162
+
163
+ result = pyogrio.read_bounds(path)
164
+ assert len(result[0]) == 177
165
+
166
+
167
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
168
+ def test_uri_local_file_dataframe(data_dir):
169
+ uri = "file://" + str(data_dir / "naturalearth_lowres/naturalearth_lowres.shp")
170
+ df = pyogrio.read_dataframe(uri)
171
+ assert len(df) == 177
172
+
173
+
174
+ def test_zip_path(naturalearth_lowres_vsi):
175
+ path, path_vsi = naturalearth_lowres_vsi
176
+ path_zip = "zip://" + str(path)
177
+
178
+ # absolute zip path
179
+ result = pyogrio.raw.read(path_zip)
180
+ assert len(result[2]) == 177
181
+
182
+ result = pyogrio.read_info(path_zip)
183
+ assert result["features"] == 177
184
+
185
+ result = pyogrio.read_bounds(path_zip)
186
+ assert len(result[0]) == 177
187
+
188
+ # absolute vsizip path
189
+ result = pyogrio.raw.read(path_vsi)
190
+ assert len(result[2]) == 177
191
+
192
+ result = pyogrio.read_info(path_vsi)
193
+ assert result["features"] == 177
194
+
195
+ result = pyogrio.read_bounds(path_vsi)
196
+ assert len(result[0]) == 177
197
+
198
+ # relative zip path
199
+ relative_path = "zip://" + path.name
200
+ with change_cwd(path.parent):
201
+ result = pyogrio.raw.read(relative_path)
202
+ assert len(result[2]) == 177
203
+
204
+ result = pyogrio.read_info(relative_path)
205
+ assert result["features"] == 177
206
+
207
+ result = pyogrio.read_bounds(relative_path)
208
+ assert len(result[0]) == 177
209
+
210
+
211
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
212
+ def test_zip_path_dataframe(naturalearth_lowres_vsi):
213
+ path, path_vsi = naturalearth_lowres_vsi
214
+ path_zip = "zip://" + str(path)
215
+
216
+ # absolute zip path
217
+ df = pyogrio.read_dataframe(path_zip)
218
+ assert len(df) == 177
219
+
220
+ # absolute vsizip path
221
+ df = pyogrio.read_dataframe(path_vsi)
222
+ assert len(df) == 177
223
+
224
+ # relative zip path
225
+ with change_cwd(path.parent):
226
+ df = pyogrio.read_dataframe("zip://" + path.name)
227
+ assert len(df) == 177
228
+
229
+
230
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
231
+ def test_detect_zip_path(tmp_path, naturalearth_lowres):
232
+ # create a zipfile with 2 shapefiles in a set of subdirectories
233
+ df = pyogrio.read_dataframe(naturalearth_lowres, where="iso_a3 in ('CAN', 'PER')")
234
+ pyogrio.write_dataframe(df.loc[df.iso_a3 == "CAN"], tmp_path / "test1.shp")
235
+ pyogrio.write_dataframe(df.loc[df.iso_a3 == "PER"], tmp_path / "test2.shp")
236
+
237
+ path = tmp_path / "test.zip"
238
+ with ZipFile(path, mode="w", compression=ZIP_DEFLATED, compresslevel=5) as out:
239
+ for ext in ["dbf", "prj", "shp", "shx"]:
240
+ filename = f"test1.{ext}"
241
+ out.write(tmp_path / filename, filename)
242
+
243
+ filename = f"test2.{ext}"
244
+ out.write(tmp_path / filename, f"/a/b/{filename}")
245
+
246
+ # defaults to the first shapefile found, at lowest subdirectory
247
+ df = pyogrio.read_dataframe(path)
248
+ assert df.iso_a3[0] == "CAN"
249
+
250
+ # selecting a shapefile from within the zip requires "!"" archive specifier
251
+ df = pyogrio.read_dataframe(f"{path}!test1.shp")
252
+ assert df.iso_a3[0] == "CAN"
253
+
254
+ df = pyogrio.read_dataframe(f"{path}!/a/b/test2.shp")
255
+ assert df.iso_a3[0] == "PER"
256
+
257
+ # specifying zip:// scheme should also work
258
+ df = pyogrio.read_dataframe(f"zip://{path}!/a/b/test2.shp")
259
+ assert df.iso_a3[0] == "PER"
260
+
261
+ # specifying /vsizip/ should also work but path must already be in GDAL ready
262
+ # format without the "!"" archive specifier
263
+ df = pyogrio.read_dataframe(f"/vsizip/{path}/a/b/test2.shp")
264
+ assert df.iso_a3[0] == "PER"
265
+
266
+
267
+ @pytest.mark.network
268
+ def test_url():
269
+ url = "https://raw.githubusercontent.com/geopandas/pyogrio/main/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shp"
270
+
271
+ result = pyogrio.raw.read(url)
272
+ assert len(result[2]) == 177
273
+
274
+ result = pyogrio.read_info(url)
275
+ assert result["features"] == 177
276
+
277
+ result = pyogrio.read_bounds(url)
278
+ assert len(result[0]) == 177
279
+
280
+
281
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
282
+ def test_url_dataframe():
283
+ url = "https://raw.githubusercontent.com/geopandas/pyogrio/main/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shp"
284
+
285
+ assert len(pyogrio.read_dataframe(url)) == 177
286
+
287
+
288
+ @pytest.mark.network
289
+ def test_url_with_zip():
290
+ url = "zip+https://s3.amazonaws.com/fiona-testing/coutwildrnp.zip"
291
+
292
+ result = pyogrio.raw.read(url)
293
+ assert len(result[2]) == 67
294
+
295
+ result = pyogrio.read_info(url)
296
+ assert result["features"] == 67
297
+
298
+ result = pyogrio.read_bounds(url)
299
+ assert len(result[0]) == 67
300
+
301
+
302
+ @pytest.mark.network
303
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
304
+ def test_url_with_zip_dataframe():
305
+ url = "zip+https://s3.amazonaws.com/fiona-testing/coutwildrnp.zip"
306
+ df = pyogrio.read_dataframe(url)
307
+ assert len(df) == 67
308
+
309
+
310
+ @pytest.fixture
311
+ def aws_env_setup(monkeypatch):
312
+ monkeypatch.setenv("AWS_NO_SIGN_REQUEST", "YES")
313
+
314
+
315
+ @pytest.mark.network
316
+ def test_uri_s3(aws_env_setup):
317
+ url = "zip+s3://fiona-testing/coutwildrnp.zip"
318
+
319
+ result = pyogrio.raw.read(url)
320
+ assert len(result[2]) == 67
321
+
322
+ result = pyogrio.read_info(url)
323
+ assert result["features"] == 67
324
+
325
+ result = pyogrio.read_bounds(url)
326
+ assert len(result[0]) == 67
327
+
328
+
329
+ @pytest.mark.network
330
+ @pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
331
+ def test_uri_s3_dataframe(aws_env_setup):
332
+ df = pyogrio.read_dataframe("zip+s3://fiona-testing/coutwildrnp.zip")
333
+ assert len(df) == 67
334
+
335
+
336
+ def test_get_vsi_path_or_buffer_obj_to_string():
337
+ path = Path("/tmp/test.gpkg")
338
+ assert get_vsi_path_or_buffer(path) == str(path)
339
+
340
+
341
+ def test_get_vsi_path_or_buffer_fixtures_to_string(tmp_path):
342
+ path = tmp_path / "test.gpkg"
343
+ assert get_vsi_path_or_buffer(path) == str(path)
344
+
345
+
346
+ @pytest.mark.parametrize(
347
+ "raw_path", ["/vsimem/test.shp.zip", "/vsizip//vsimem/test.shp.zip"]
348
+ )
349
+ def test_vsimem_path_exception(raw_path):
350
+ with pytest.raises(ValueError, match=""):
351
+ vsi_path(raw_path)