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.
- pyogrio/.dylibs/libgdal.37.3.11.4.dylib +0 -0
- pyogrio/__init__.py +57 -0
- pyogrio/_compat.py +54 -0
- pyogrio/_env.py +59 -0
- pyogrio/_err.cpython-314t-darwin.so +0 -0
- pyogrio/_geometry.cpython-314t-darwin.so +0 -0
- pyogrio/_io.cpython-314t-darwin.so +0 -0
- pyogrio/_ogr.cpython-314t-darwin.so +0 -0
- pyogrio/_version.py +21 -0
- pyogrio/_vsi.cpython-314t-darwin.so +0 -0
- pyogrio/core.py +387 -0
- pyogrio/errors.py +25 -0
- pyogrio/gdal_data/GDAL-targets-release.cmake +19 -0
- pyogrio/gdal_data/GDAL-targets.cmake +106 -0
- pyogrio/gdal_data/GDALConfig.cmake +24 -0
- pyogrio/gdal_data/GDALConfigVersion.cmake +65 -0
- pyogrio/gdal_data/GDALLogoBW.svg +138 -0
- pyogrio/gdal_data/GDALLogoColor.svg +126 -0
- pyogrio/gdal_data/GDALLogoGS.svg +126 -0
- pyogrio/gdal_data/LICENSE.TXT +467 -0
- pyogrio/gdal_data/MM_m_idofic.csv +321 -0
- pyogrio/gdal_data/copyright +467 -0
- pyogrio/gdal_data/cubewerx_extra.wkt +48 -0
- pyogrio/gdal_data/default.rsc +0 -0
- pyogrio/gdal_data/ecw_cs.wkt +1453 -0
- pyogrio/gdal_data/eedaconf.json +23 -0
- pyogrio/gdal_data/epsg.wkt +1 -0
- pyogrio/gdal_data/esri_StatePlane_extra.wkt +631 -0
- pyogrio/gdal_data/gdal_algorithm.schema.json +220 -0
- pyogrio/gdal_data/gdalg.schema.json +36 -0
- pyogrio/gdal_data/gdalicon.png +0 -0
- pyogrio/gdal_data/gdalinfo_output.schema.json +390 -0
- pyogrio/gdal_data/gdalmdiminfo_output.schema.json +326 -0
- pyogrio/gdal_data/gdaltileindex.xsd +253 -0
- pyogrio/gdal_data/gdalvrt.xsd +927 -0
- pyogrio/gdal_data/gfs.xsd +246 -0
- pyogrio/gdal_data/gml_registry.xml +117 -0
- pyogrio/gdal_data/gml_registry.xsd +66 -0
- pyogrio/gdal_data/grib2_center.csv +251 -0
- pyogrio/gdal_data/grib2_process.csv +102 -0
- pyogrio/gdal_data/grib2_subcenter.csv +63 -0
- pyogrio/gdal_data/grib2_table_4_2_0_0.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_1.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_13.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_14.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_15.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_16.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_17.csv +11 -0
- pyogrio/gdal_data/grib2_table_4_2_0_18.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_19.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_190.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_191.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_2.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_20.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_21.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_3.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_4.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_5.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_6.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_0_7.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_10_0.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_10_1.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_10_191.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_10_2.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_10_3.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_10_4.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_1_0.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_1_1.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_1_2.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_20_0.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_20_1.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_20_2.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_2_0.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_2_3.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_2_4.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_2_5.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_2_6.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_3_0.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_3_1.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_3_2.csv +28 -0
- pyogrio/gdal_data/grib2_table_4_2_3_3.csv +8 -0
- pyogrio/gdal_data/grib2_table_4_2_3_4.csv +14 -0
- pyogrio/gdal_data/grib2_table_4_2_3_5.csv +11 -0
- pyogrio/gdal_data/grib2_table_4_2_3_6.csv +11 -0
- pyogrio/gdal_data/grib2_table_4_2_4_0.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_4_1.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_4_10.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_4_2.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_4_3.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_4_4.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_4_5.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_4_6.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_4_7.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_4_8.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_4_9.csv +261 -0
- pyogrio/gdal_data/grib2_table_4_2_local_Canada.csv +5 -0
- pyogrio/gdal_data/grib2_table_4_2_local_HPC.csv +2 -0
- pyogrio/gdal_data/grib2_table_4_2_local_MRMS.csv +175 -0
- pyogrio/gdal_data/grib2_table_4_2_local_NCEP.csv +401 -0
- pyogrio/gdal_data/grib2_table_4_2_local_NDFD.csv +38 -0
- pyogrio/gdal_data/grib2_table_4_2_local_index.csv +7 -0
- pyogrio/gdal_data/grib2_table_4_5.csv +261 -0
- pyogrio/gdal_data/grib2_table_versions.csv +3 -0
- pyogrio/gdal_data/gt_datum.csv +229 -0
- pyogrio/gdal_data/gt_ellips.csv +24 -0
- pyogrio/gdal_data/header.dxf +1124 -0
- pyogrio/gdal_data/inspire_cp_BasicPropertyUnit.gfs +57 -0
- pyogrio/gdal_data/inspire_cp_CadastralBoundary.gfs +60 -0
- pyogrio/gdal_data/inspire_cp_CadastralParcel.gfs +81 -0
- pyogrio/gdal_data/inspire_cp_CadastralZoning.gfs +161 -0
- pyogrio/gdal_data/jpfgdgml_AdmArea.gfs +59 -0
- pyogrio/gdal_data/jpfgdgml_AdmBdry.gfs +49 -0
- pyogrio/gdal_data/jpfgdgml_AdmPt.gfs +59 -0
- pyogrio/gdal_data/jpfgdgml_BldA.gfs +54 -0
- pyogrio/gdal_data/jpfgdgml_BldL.gfs +54 -0
- pyogrio/gdal_data/jpfgdgml_Cntr.gfs +54 -0
- pyogrio/gdal_data/jpfgdgml_CommBdry.gfs +49 -0
- pyogrio/gdal_data/jpfgdgml_CommPt.gfs +59 -0
- pyogrio/gdal_data/jpfgdgml_Cstline.gfs +54 -0
- pyogrio/gdal_data/jpfgdgml_ElevPt.gfs +54 -0
- pyogrio/gdal_data/jpfgdgml_GCP.gfs +94 -0
- pyogrio/gdal_data/jpfgdgml_LeveeEdge.gfs +49 -0
- pyogrio/gdal_data/jpfgdgml_RailCL.gfs +54 -0
- pyogrio/gdal_data/jpfgdgml_RdASL.gfs +44 -0
- pyogrio/gdal_data/jpfgdgml_RdArea.gfs +54 -0
- pyogrio/gdal_data/jpfgdgml_RdCompt.gfs +59 -0
- pyogrio/gdal_data/jpfgdgml_RdEdg.gfs +59 -0
- pyogrio/gdal_data/jpfgdgml_RdMgtBdry.gfs +49 -0
- pyogrio/gdal_data/jpfgdgml_RdSgmtA.gfs +59 -0
- pyogrio/gdal_data/jpfgdgml_RvrMgtBdry.gfs +49 -0
- pyogrio/gdal_data/jpfgdgml_SBAPt.gfs +49 -0
- pyogrio/gdal_data/jpfgdgml_SBArea.gfs +54 -0
- pyogrio/gdal_data/jpfgdgml_SBBdry.gfs +44 -0
- pyogrio/gdal_data/jpfgdgml_WA.gfs +54 -0
- pyogrio/gdal_data/jpfgdgml_WL.gfs +54 -0
- pyogrio/gdal_data/jpfgdgml_WStrA.gfs +54 -0
- pyogrio/gdal_data/jpfgdgml_WStrL.gfs +54 -0
- pyogrio/gdal_data/leaflet_template.html +102 -0
- pyogrio/gdal_data/nitf_spec.xml +3288 -0
- pyogrio/gdal_data/nitf_spec.xsd +171 -0
- pyogrio/gdal_data/ogr_fields_override.schema.json +125 -0
- pyogrio/gdal_data/ogrinfo_output.schema.json +528 -0
- pyogrio/gdal_data/ogrvrt.xsd +528 -0
- pyogrio/gdal_data/osmconf.ini +134 -0
- pyogrio/gdal_data/ozi_datum.csv +131 -0
- pyogrio/gdal_data/ozi_ellips.csv +35 -0
- pyogrio/gdal_data/pci_datum.txt +530 -0
- pyogrio/gdal_data/pci_ellips.txt +129 -0
- pyogrio/gdal_data/pdfcomposition.xsd +703 -0
- pyogrio/gdal_data/pds4_template.xml +65 -0
- pyogrio/gdal_data/plscenesconf.json +1985 -0
- pyogrio/gdal_data/ruian_vf_ob_v1.gfs +1455 -0
- pyogrio/gdal_data/ruian_vf_st_uvoh_v1.gfs +86 -0
- pyogrio/gdal_data/ruian_vf_st_v1.gfs +1489 -0
- pyogrio/gdal_data/ruian_vf_v1.gfs +2126 -0
- pyogrio/gdal_data/s57agencies.csv +249 -0
- pyogrio/gdal_data/s57attributes.csv +484 -0
- pyogrio/gdal_data/s57expectedinput.csv +1008 -0
- pyogrio/gdal_data/s57objectclasses.csv +287 -0
- pyogrio/gdal_data/seed_2d.dgn +0 -0
- pyogrio/gdal_data/seed_3d.dgn +0 -0
- pyogrio/gdal_data/stateplane.csv +259 -0
- pyogrio/gdal_data/template_tiles.mapml +28 -0
- pyogrio/gdal_data/tms_LINZAntarticaMapTileGrid.json +190 -0
- pyogrio/gdal_data/tms_MapML_APSTILE.json +268 -0
- pyogrio/gdal_data/tms_MapML_CBMTILE.json +346 -0
- pyogrio/gdal_data/tms_NZTM2000.json +243 -0
- pyogrio/gdal_data/trailer.dxf +434 -0
- pyogrio/gdal_data/usage +4 -0
- pyogrio/gdal_data/vcpkg-cmake-wrapper.cmake +23 -0
- pyogrio/gdal_data/vcpkg.spdx.json +291 -0
- pyogrio/gdal_data/vcpkg_abi_info.txt +45 -0
- pyogrio/gdal_data/vdv452.xml +349 -0
- pyogrio/gdal_data/vdv452.xsd +45 -0
- pyogrio/gdal_data/vicar.json +164 -0
- pyogrio/geopandas.py +978 -0
- pyogrio/proj_data/CH +22 -0
- pyogrio/proj_data/GL27 +23 -0
- pyogrio/proj_data/ITRF2000 +24 -0
- pyogrio/proj_data/ITRF2008 +94 -0
- pyogrio/proj_data/ITRF2014 +55 -0
- pyogrio/proj_data/ITRF2020 +91 -0
- pyogrio/proj_data/copyright +34 -0
- pyogrio/proj_data/deformation_model.schema.json +582 -0
- pyogrio/proj_data/nad.lst +142 -0
- pyogrio/proj_data/nad27 +810 -0
- pyogrio/proj_data/nad83 +745 -0
- pyogrio/proj_data/other.extra +53 -0
- pyogrio/proj_data/proj-config-version.cmake +44 -0
- pyogrio/proj_data/proj-config.cmake +79 -0
- pyogrio/proj_data/proj-targets-release.cmake +19 -0
- pyogrio/proj_data/proj-targets.cmake +107 -0
- pyogrio/proj_data/proj.db +0 -0
- pyogrio/proj_data/proj.ini +59 -0
- pyogrio/proj_data/proj4-targets-release.cmake +19 -0
- pyogrio/proj_data/proj4-targets.cmake +107 -0
- pyogrio/proj_data/projjson.schema.json +1174 -0
- pyogrio/proj_data/triangulation.schema.json +214 -0
- pyogrio/proj_data/usage +9 -0
- pyogrio/proj_data/vcpkg.spdx.json +203 -0
- pyogrio/proj_data/vcpkg_abi_info.txt +28 -0
- pyogrio/proj_data/world +214 -0
- pyogrio/raw.py +897 -0
- pyogrio/tests/__init__.py +0 -0
- pyogrio/tests/conftest.py +588 -0
- pyogrio/tests/fixtures/README.md +108 -0
- pyogrio/tests/fixtures/curve.gpkg +0 -0
- pyogrio/tests/fixtures/curvepolygon.gpkg +0 -0
- pyogrio/tests/fixtures/line_zm.gpkg +0 -0
- pyogrio/tests/fixtures/list_field_values_file.parquet +0 -0
- pyogrio/tests/fixtures/list_nested_struct_file.parquet +0 -0
- pyogrio/tests/fixtures/multisurface.gpkg +0 -0
- pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.cpg +1 -0
- pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.dbf +0 -0
- pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.prj +1 -0
- pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shp +0 -0
- pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shx +0 -0
- pyogrio/tests/fixtures/sample.osm.pbf +0 -0
- pyogrio/tests/fixtures/test_gpkg_nulls.gpkg +0 -0
- pyogrio/tests/test_arrow.py +1160 -0
- pyogrio/tests/test_core.py +702 -0
- pyogrio/tests/test_geopandas_io.py +3218 -0
- pyogrio/tests/test_path.py +374 -0
- pyogrio/tests/test_raw_io.py +1473 -0
- pyogrio/tests/test_util.py +56 -0
- pyogrio/util.py +258 -0
- pyogrio-0.12.0.dist-info/METADATA +125 -0
- pyogrio-0.12.0.dist-info/RECORD +231 -0
- pyogrio-0.12.0.dist-info/WHEEL +6 -0
- pyogrio-0.12.0.dist-info/licenses/LICENSE +21 -0
- 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)
|