pyogrio 0.9.0__cp312-cp312-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.
Potentially problematic release.
This version of pyogrio might be problematic. Click here for more details.
- pyogrio/.dylibs/libgdal.34.3.8.5.dylib +0 -0
- pyogrio/__init__.py +48 -0
- pyogrio/_compat.py +41 -0
- pyogrio/_env.py +61 -0
- pyogrio/_err.cpython-312-darwin.so +0 -0
- pyogrio/_err.pxd +4 -0
- pyogrio/_err.pyx +250 -0
- pyogrio/_geometry.cpython-312-darwin.so +0 -0
- pyogrio/_geometry.pxd +4 -0
- pyogrio/_geometry.pyx +129 -0
- pyogrio/_io.cpython-312-darwin.so +0 -0
- pyogrio/_io.pxd +0 -0
- pyogrio/_io.pyx +2742 -0
- pyogrio/_ogr.cpython-312-darwin.so +0 -0
- pyogrio/_ogr.pxd +444 -0
- pyogrio/_ogr.pyx +346 -0
- pyogrio/_version.py +21 -0
- pyogrio/_vsi.cpython-312-darwin.so +0 -0
- pyogrio/_vsi.pxd +4 -0
- pyogrio/_vsi.pyx +140 -0
- pyogrio/arrow_bridge.h +115 -0
- pyogrio/core.py +320 -0
- pyogrio/errors.py +32 -0
- pyogrio/gdal_data/GDAL-targets-release.cmake +19 -0
- pyogrio/gdal_data/GDAL-targets.cmake +105 -0
- pyogrio/gdal_data/GDALConfig.cmake +25 -0
- pyogrio/gdal_data/GDALConfigVersion.cmake +85 -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/bag_template.xml +201 -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/gdalicon.png +0 -0
- pyogrio/gdal_data/gdalinfo_output.schema.json +346 -0
- pyogrio/gdal_data/gdalmdiminfo_output.schema.json +321 -0
- pyogrio/gdal_data/gdalvrt.xsd +772 -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/gmlasconf.xml +169 -0
- pyogrio/gdal_data/gmlasconf.xsd +1066 -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/netcdf_config.xsd +143 -0
- pyogrio/gdal_data/nitf_spec.xml +3306 -0
- pyogrio/gdal_data/nitf_spec.xsd +189 -0
- pyogrio/gdal_data/ogrinfo_output.schema.json +505 -0
- pyogrio/gdal_data/ogrvrt.xsd +543 -0
- pyogrio/gdal_data/osmconf.ini +132 -0
- pyogrio/gdal_data/ozi_datum.csv +131 -0
- pyogrio/gdal_data/ozi_ellips.csv +35 -0
- pyogrio/gdal_data/pci_datum.txt +463 -0
- pyogrio/gdal_data/pci_ellips.txt +77 -0
- pyogrio/gdal_data/pdfcomposition.xsd +721 -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 +264 -0
- pyogrio/gdal_data/vcpkg_abi_info.txt +41 -0
- pyogrio/gdal_data/vdv452.xml +367 -0
- pyogrio/gdal_data/vdv452.xsd +63 -0
- pyogrio/gdal_data/vicar.json +164 -0
- pyogrio/geopandas.py +675 -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/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 +51 -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 +4 -0
- pyogrio/proj_data/vcpkg.spdx.json +198 -0
- pyogrio/proj_data/vcpkg_abi_info.txt +27 -0
- pyogrio/proj_data/world +214 -0
- pyogrio/raw.py +871 -0
- pyogrio/tests/__init__.py +0 -0
- pyogrio/tests/conftest.py +204 -0
- pyogrio/tests/fixtures/README.md +89 -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/poly_not_enough_points.shp.zip +0 -0
- pyogrio/tests/fixtures/sample.osm.pbf +0 -0
- pyogrio/tests/fixtures/test_datetime.geojson +7 -0
- pyogrio/tests/fixtures/test_datetime_tz.geojson +8 -0
- pyogrio/tests/fixtures/test_fgdb.gdb.zip +0 -0
- pyogrio/tests/fixtures/test_gpkg_nulls.gpkg +0 -0
- pyogrio/tests/fixtures/test_multisurface.gpkg +0 -0
- pyogrio/tests/fixtures/test_nested.geojson +18 -0
- pyogrio/tests/fixtures/test_ogr_types_list.geojson +12 -0
- pyogrio/tests/test_arrow.py +1041 -0
- pyogrio/tests/test_core.py +588 -0
- pyogrio/tests/test_geopandas_io.py +2174 -0
- pyogrio/tests/test_path.py +352 -0
- pyogrio/tests/test_raw_io.py +1404 -0
- pyogrio/util.py +223 -0
- pyogrio-0.9.0.dist-info/LICENSE +21 -0
- pyogrio-0.9.0.dist-info/METADATA +100 -0
- pyogrio-0.9.0.dist-info/RECORD +239 -0
- pyogrio-0.9.0.dist-info/WHEEL +5 -0
- pyogrio-0.9.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,352 @@
|
|
|
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
|
+
("/home/folder # with hash/data.gpkg", "/home/folder # with hash/data.gpkg"),
|
|
39
|
+
# cloud URIs
|
|
40
|
+
("https://testing/data.gpkg", "/vsicurl/https://testing/data.gpkg"),
|
|
41
|
+
("s3://testing/data.gpkg", "/vsis3/testing/data.gpkg"),
|
|
42
|
+
("gs://testing/data.gpkg", "/vsigs/testing/data.gpkg"),
|
|
43
|
+
("az://testing/data.gpkg", "/vsiaz/testing/data.gpkg"),
|
|
44
|
+
("adl://testing/data.gpkg", "/vsiadls/testing/data.gpkg"),
|
|
45
|
+
("adls://testing/data.gpkg", "/vsiadls/testing/data.gpkg"),
|
|
46
|
+
("hdfs://testing/data.gpkg", "/vsihdfs/testing/data.gpkg"),
|
|
47
|
+
("webhdfs://testing/data.gpkg", "/vsiwebhdfs/testing/data.gpkg"),
|
|
48
|
+
# archives
|
|
49
|
+
("zip://data.zip", "/vsizip/data.zip"),
|
|
50
|
+
("tar://data.tar", "/vsitar/data.tar"),
|
|
51
|
+
("gzip://data.gz", "/vsigzip/data.gz"),
|
|
52
|
+
("tar://./my.tar!my.geojson", "/vsitar/./my.tar/my.geojson"),
|
|
53
|
+
(
|
|
54
|
+
"zip://home/data/shapefile.zip!layer.shp",
|
|
55
|
+
"/vsizip/home/data/shapefile.zip/layer.shp",
|
|
56
|
+
),
|
|
57
|
+
# combined schemes
|
|
58
|
+
("zip+s3://testing/shapefile.zip", "/vsizip/vsis3/testing/shapefile.zip"),
|
|
59
|
+
(
|
|
60
|
+
"zip+https://s3.amazonaws.com/testing/shapefile.zip",
|
|
61
|
+
"/vsizip/vsicurl/https://s3.amazonaws.com/testing/shapefile.zip",
|
|
62
|
+
),
|
|
63
|
+
# auto-prefix zip files
|
|
64
|
+
("test.zip", "/vsizip/test.zip"),
|
|
65
|
+
("/a/b/test.zip", "/vsizip//a/b/test.zip"),
|
|
66
|
+
("a/b/test.zip", "/vsizip/a/b/test.zip"),
|
|
67
|
+
# archives using ! notation should be prefixed by vsizip
|
|
68
|
+
("test.zip!item.shp", "/vsizip/test.zip/item.shp"),
|
|
69
|
+
("test.zip!/a/b/item.shp", "/vsizip/test.zip/a/b/item.shp"),
|
|
70
|
+
("test.zip!a/b/item.shp", "/vsizip/test.zip/a/b/item.shp"),
|
|
71
|
+
("/vsizip/test.zip/a/b/item.shp", "/vsizip/test.zip/a/b/item.shp"),
|
|
72
|
+
("zip:///test.zip/a/b/item.shp", "/vsizip//test.zip/a/b/item.shp"),
|
|
73
|
+
# auto-prefix remote zip files
|
|
74
|
+
(
|
|
75
|
+
"https://s3.amazonaws.com/testing/test.zip",
|
|
76
|
+
"/vsizip/vsicurl/https://s3.amazonaws.com/testing/test.zip",
|
|
77
|
+
),
|
|
78
|
+
(
|
|
79
|
+
"https://s3.amazonaws.com/testing/test.zip!/a/b/item.shp",
|
|
80
|
+
"/vsizip/vsicurl/https://s3.amazonaws.com/testing/test.zip/a/b/item.shp",
|
|
81
|
+
),
|
|
82
|
+
("s3://testing/test.zip", "/vsizip/vsis3/testing/test.zip"),
|
|
83
|
+
(
|
|
84
|
+
"s3://testing/test.zip!a/b/item.shp",
|
|
85
|
+
"/vsizip/vsis3/testing/test.zip/a/b/item.shp",
|
|
86
|
+
),
|
|
87
|
+
],
|
|
88
|
+
)
|
|
89
|
+
def test_vsi_path(path, expected):
|
|
90
|
+
assert vsi_path(path) == expected
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_vsi_path_unknown():
|
|
94
|
+
# unrecognized URI gets passed through as is
|
|
95
|
+
assert vsi_path("s4://test/data.geojson") == "s4://test/data.geojson"
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def test_vsi_handling_read_functions(naturalearth_lowres_vsi):
|
|
99
|
+
# test that all different read entry points have the path handling
|
|
100
|
+
# (a zip:// path would otherwise fail)
|
|
101
|
+
path, _ = naturalearth_lowres_vsi
|
|
102
|
+
path = "zip://" + str(path)
|
|
103
|
+
|
|
104
|
+
result = pyogrio.raw.read(path)
|
|
105
|
+
assert len(result[2]) == 177
|
|
106
|
+
|
|
107
|
+
result = pyogrio.read_info(path)
|
|
108
|
+
assert result["features"] == 177
|
|
109
|
+
|
|
110
|
+
result = pyogrio.read_bounds(path)
|
|
111
|
+
assert len(result[0]) == 177
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
|
|
115
|
+
def test_vsi_handling_read_dataframe(naturalearth_lowres_vsi):
|
|
116
|
+
path, _ = naturalearth_lowres_vsi
|
|
117
|
+
path = "zip://" + str(path)
|
|
118
|
+
|
|
119
|
+
result = pyogrio.read_dataframe(path)
|
|
120
|
+
assert len(result) == 177
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
@pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
|
|
124
|
+
def test_path_absolute(data_dir):
|
|
125
|
+
# pathlib path
|
|
126
|
+
path = data_dir / "naturalearth_lowres/naturalearth_lowres.shp"
|
|
127
|
+
df = pyogrio.read_dataframe(path)
|
|
128
|
+
assert len(df) == 177
|
|
129
|
+
|
|
130
|
+
# str path
|
|
131
|
+
df = pyogrio.read_dataframe(str(path))
|
|
132
|
+
assert len(df) == 177
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def test_path_relative(data_dir):
|
|
136
|
+
path = "naturalearth_lowres/naturalearth_lowres.shp"
|
|
137
|
+
|
|
138
|
+
with change_cwd(data_dir):
|
|
139
|
+
result = pyogrio.raw.read(path)
|
|
140
|
+
assert len(result[2]) == 177
|
|
141
|
+
|
|
142
|
+
result = pyogrio.read_info(path)
|
|
143
|
+
assert result["features"] == 177
|
|
144
|
+
|
|
145
|
+
result = pyogrio.read_bounds(path)
|
|
146
|
+
assert len(result[0]) == 177
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
|
|
150
|
+
def test_path_relative_dataframe(data_dir):
|
|
151
|
+
with change_cwd(data_dir):
|
|
152
|
+
df = pyogrio.read_dataframe("naturalearth_lowres/naturalearth_lowres.shp")
|
|
153
|
+
assert len(df) == 177
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def test_uri_local_file(data_dir):
|
|
157
|
+
path = "file://" + str(data_dir / "naturalearth_lowres/naturalearth_lowres.shp")
|
|
158
|
+
result = pyogrio.raw.read(path)
|
|
159
|
+
assert len(result[2]) == 177
|
|
160
|
+
|
|
161
|
+
result = pyogrio.read_info(path)
|
|
162
|
+
assert result["features"] == 177
|
|
163
|
+
|
|
164
|
+
result = pyogrio.read_bounds(path)
|
|
165
|
+
assert len(result[0]) == 177
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
@pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
|
|
169
|
+
def test_uri_local_file_dataframe(data_dir):
|
|
170
|
+
uri = "file://" + str(data_dir / "naturalearth_lowres/naturalearth_lowres.shp")
|
|
171
|
+
df = pyogrio.read_dataframe(uri)
|
|
172
|
+
assert len(df) == 177
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def test_zip_path(naturalearth_lowres_vsi):
|
|
176
|
+
path, path_vsi = naturalearth_lowres_vsi
|
|
177
|
+
path_zip = "zip://" + str(path)
|
|
178
|
+
|
|
179
|
+
# absolute zip path
|
|
180
|
+
result = pyogrio.raw.read(path_zip)
|
|
181
|
+
assert len(result[2]) == 177
|
|
182
|
+
|
|
183
|
+
result = pyogrio.read_info(path_zip)
|
|
184
|
+
assert result["features"] == 177
|
|
185
|
+
|
|
186
|
+
result = pyogrio.read_bounds(path_zip)
|
|
187
|
+
assert len(result[0]) == 177
|
|
188
|
+
|
|
189
|
+
# absolute vsizip path
|
|
190
|
+
result = pyogrio.raw.read(path_vsi)
|
|
191
|
+
assert len(result[2]) == 177
|
|
192
|
+
|
|
193
|
+
result = pyogrio.read_info(path_vsi)
|
|
194
|
+
assert result["features"] == 177
|
|
195
|
+
|
|
196
|
+
result = pyogrio.read_bounds(path_vsi)
|
|
197
|
+
assert len(result[0]) == 177
|
|
198
|
+
|
|
199
|
+
# relative zip path
|
|
200
|
+
relative_path = "zip://" + path.name
|
|
201
|
+
with change_cwd(path.parent):
|
|
202
|
+
result = pyogrio.raw.read(relative_path)
|
|
203
|
+
assert len(result[2]) == 177
|
|
204
|
+
|
|
205
|
+
result = pyogrio.read_info(relative_path)
|
|
206
|
+
assert result["features"] == 177
|
|
207
|
+
|
|
208
|
+
result = pyogrio.read_bounds(relative_path)
|
|
209
|
+
assert len(result[0]) == 177
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
|
|
213
|
+
def test_zip_path_dataframe(naturalearth_lowres_vsi):
|
|
214
|
+
path, path_vsi = naturalearth_lowres_vsi
|
|
215
|
+
path_zip = "zip://" + str(path)
|
|
216
|
+
|
|
217
|
+
# absolute zip path
|
|
218
|
+
df = pyogrio.read_dataframe(path_zip)
|
|
219
|
+
assert len(df) == 177
|
|
220
|
+
|
|
221
|
+
# absolute vsizip path
|
|
222
|
+
df = pyogrio.read_dataframe(path_vsi)
|
|
223
|
+
assert len(df) == 177
|
|
224
|
+
|
|
225
|
+
# relative zip path
|
|
226
|
+
with change_cwd(path.parent):
|
|
227
|
+
df = pyogrio.read_dataframe("zip://" + path.name)
|
|
228
|
+
assert len(df) == 177
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
@pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
|
|
232
|
+
def test_detect_zip_path(tmp_path, naturalearth_lowres):
|
|
233
|
+
# create a zipfile with 2 shapefiles in a set of subdirectories
|
|
234
|
+
df = pyogrio.read_dataframe(naturalearth_lowres, where="iso_a3 in ('CAN', 'PER')")
|
|
235
|
+
pyogrio.write_dataframe(df.loc[df.iso_a3 == "CAN"], tmp_path / "test1.shp")
|
|
236
|
+
pyogrio.write_dataframe(df.loc[df.iso_a3 == "PER"], tmp_path / "test2.shp")
|
|
237
|
+
|
|
238
|
+
path = tmp_path / "test.zip"
|
|
239
|
+
with ZipFile(path, mode="w", compression=ZIP_DEFLATED, compresslevel=5) as out:
|
|
240
|
+
for ext in ["dbf", "prj", "shp", "shx"]:
|
|
241
|
+
filename = f"test1.{ext}"
|
|
242
|
+
out.write(tmp_path / filename, filename)
|
|
243
|
+
|
|
244
|
+
filename = f"test2.{ext}"
|
|
245
|
+
out.write(tmp_path / filename, f"/a/b/{filename}")
|
|
246
|
+
|
|
247
|
+
# defaults to the first shapefile found, at lowest subdirectory
|
|
248
|
+
df = pyogrio.read_dataframe(path)
|
|
249
|
+
assert df.iso_a3[0] == "CAN"
|
|
250
|
+
|
|
251
|
+
# selecting a shapefile from within the zip requires "!"" archive specifier
|
|
252
|
+
df = pyogrio.read_dataframe(f"{path}!test1.shp")
|
|
253
|
+
assert df.iso_a3[0] == "CAN"
|
|
254
|
+
|
|
255
|
+
df = pyogrio.read_dataframe(f"{path}!/a/b/test2.shp")
|
|
256
|
+
assert df.iso_a3[0] == "PER"
|
|
257
|
+
|
|
258
|
+
# specifying zip:// scheme should also work
|
|
259
|
+
df = pyogrio.read_dataframe(f"zip://{path}!/a/b/test2.shp")
|
|
260
|
+
assert df.iso_a3[0] == "PER"
|
|
261
|
+
|
|
262
|
+
# specifying /vsizip/ should also work but path must already be in GDAL ready
|
|
263
|
+
# format without the "!"" archive specifier
|
|
264
|
+
df = pyogrio.read_dataframe(f"/vsizip/{path}/a/b/test2.shp")
|
|
265
|
+
assert df.iso_a3[0] == "PER"
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
@pytest.mark.network
|
|
269
|
+
def test_url():
|
|
270
|
+
url = "https://raw.githubusercontent.com/geopandas/pyogrio/main/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shp"
|
|
271
|
+
|
|
272
|
+
result = pyogrio.raw.read(url)
|
|
273
|
+
assert len(result[2]) == 177
|
|
274
|
+
|
|
275
|
+
result = pyogrio.read_info(url)
|
|
276
|
+
assert result["features"] == 177
|
|
277
|
+
|
|
278
|
+
result = pyogrio.read_bounds(url)
|
|
279
|
+
assert len(result[0]) == 177
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
@pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
|
|
283
|
+
def test_url_dataframe():
|
|
284
|
+
url = "https://raw.githubusercontent.com/geopandas/pyogrio/main/pyogrio/tests/fixtures/naturalearth_lowres/naturalearth_lowres.shp"
|
|
285
|
+
|
|
286
|
+
assert len(pyogrio.read_dataframe(url)) == 177
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
@pytest.mark.network
|
|
290
|
+
def test_url_with_zip():
|
|
291
|
+
url = "zip+https://s3.amazonaws.com/fiona-testing/coutwildrnp.zip"
|
|
292
|
+
|
|
293
|
+
result = pyogrio.raw.read(url)
|
|
294
|
+
assert len(result[2]) == 67
|
|
295
|
+
|
|
296
|
+
result = pyogrio.read_info(url)
|
|
297
|
+
assert result["features"] == 67
|
|
298
|
+
|
|
299
|
+
result = pyogrio.read_bounds(url)
|
|
300
|
+
assert len(result[0]) == 67
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
@pytest.mark.network
|
|
304
|
+
@pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
|
|
305
|
+
def test_url_with_zip_dataframe():
|
|
306
|
+
url = "zip+https://s3.amazonaws.com/fiona-testing/coutwildrnp.zip"
|
|
307
|
+
df = pyogrio.read_dataframe(url)
|
|
308
|
+
assert len(df) == 67
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
@pytest.fixture
|
|
312
|
+
def aws_env_setup(monkeypatch):
|
|
313
|
+
monkeypatch.setenv("AWS_NO_SIGN_REQUEST", "YES")
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
@pytest.mark.network
|
|
317
|
+
def test_uri_s3(aws_env_setup):
|
|
318
|
+
url = "zip+s3://fiona-testing/coutwildrnp.zip"
|
|
319
|
+
|
|
320
|
+
result = pyogrio.raw.read(url)
|
|
321
|
+
assert len(result[2]) == 67
|
|
322
|
+
|
|
323
|
+
result = pyogrio.read_info(url)
|
|
324
|
+
assert result["features"] == 67
|
|
325
|
+
|
|
326
|
+
result = pyogrio.read_bounds(url)
|
|
327
|
+
assert len(result[0]) == 67
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
@pytest.mark.network
|
|
331
|
+
@pytest.mark.skipif(not has_geopandas, reason="GeoPandas not available")
|
|
332
|
+
def test_uri_s3_dataframe(aws_env_setup):
|
|
333
|
+
df = pyogrio.read_dataframe("zip+s3://fiona-testing/coutwildrnp.zip")
|
|
334
|
+
assert len(df) == 67
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def test_get_vsi_path_or_buffer_obj_to_string():
|
|
338
|
+
path = Path("/tmp/test.gpkg")
|
|
339
|
+
assert get_vsi_path_or_buffer(path) == str(path)
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def test_get_vsi_path_or_buffer_fixtures_to_string(tmp_path):
|
|
343
|
+
path = tmp_path / "test.gpkg"
|
|
344
|
+
assert get_vsi_path_or_buffer(path) == str(path)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
@pytest.mark.parametrize(
|
|
348
|
+
"raw_path", ["/vsimem/test.shp.zip", "/vsizip//vsimem/test.shp.zip"]
|
|
349
|
+
)
|
|
350
|
+
def test_vsimem_path_exception(raw_path):
|
|
351
|
+
with pytest.raises(ValueError, match=""):
|
|
352
|
+
vsi_path(raw_path)
|