Commit 6bf1766d authored by Benjamin Pillot's avatar Benjamin Pillot
Browse files

Add osgeo support for imports:

* for gdal versions > 3.1, use "from osgeo import ..."
parent c4651169
......@@ -8,7 +8,6 @@ More detailed description.
import multiprocessing as mp
import numpy as np
import ogr
import pyproj
from pyrasta.io_.files import _copy_to_file
from pyrasta.tools.calculator import _op, _raster_calculation, _log, _log10
......@@ -26,7 +25,11 @@ from pyrasta.tools.stats import _histogram, _zonal_stats
from pyrasta.tools.windows import _windowing
from pyrasta.utils import lazyproperty, grid, MP_CHUNK_SIZE
import gdal
try:
from osgeo import gdal, ogr
except ImportError:
import gdal
import ogr
gdal.UseExceptions()
......
......@@ -5,7 +5,11 @@
More detailed description.
"""
import osr
try:
from osgeo import osr
except ImportError:
import osr
import pyproj
......
......@@ -9,7 +9,10 @@ from functools import wraps
from pyrasta.io_.files import RasterTempFile
import gdal
try:
from osgeo import gdal
except ImportError:
import gdal
def _return_raster(function):
......
......@@ -14,7 +14,10 @@ from pyrasta.tools.windows import get_block_windows, get_xy_block_windows
from pyrasta.utils import split_into_chunks
from tqdm import tqdm
import gdal
try:
from osgeo import gdal
except ImportError:
import gdal
OP_WINDOW_SIZE = 1000
......
......@@ -8,7 +8,10 @@ from pyrasta.io_ import ESRI_DRIVER
from pyrasta.io_.files import RasterTempFile, ShapeTempFile
from pyrasta.tools import _return_raster, _gdal_temp_dataset
import gdal
try:
from osgeo import gdal
except ImportError:
import gdal
@_return_raster
......
......@@ -8,13 +8,16 @@ from pyrasta.crs import srs_from
from pyrasta.io_.files import VrtTempFile, _copy_to_file
from pyrasta.tools import _gdal_temp_dataset, _return_raster, _clone_gdal_dataset
# from osgeo import gdal_array
import affine
import gdal
from pyrasta.tools.mapping import NUMPY_TO_GDAL
try:
from osgeo import gdal
except ImportError:
import gdal
@_return_raster
def _align_raster(in_raster, out_file, on_raster):
""" Align raster on other raster
......
......@@ -6,7 +6,10 @@ More detailed description.
"""
from pyrasta.tools import _return_raster
import gdal
try:
from osgeo import gdal
except ImportError:
import gdal
@_return_raster
......
......@@ -4,10 +4,14 @@
More detailed description.
"""
import gdal
from pyrasta.tools import _clone_gdal_dataset, _return_raster
from pyrasta.utils import gdal_progress_bar
try:
from osgeo import gdal
except ImportError:
import gdal
@_return_raster
def _sieve(raster, out_file, threshold, connectedness, progress_bar):
......
......@@ -4,11 +4,13 @@
More detailed description.
"""
from pyrasta.io_.files import RasterTempFile
import gdal
from pyrasta.tools import _return_raster
try:
from osgeo import gdal
except ImportError:
import gdal
@_return_raster
def _merge(raster_class, out_file, gdal_driver,
......
......@@ -4,13 +4,15 @@
More detailed description.
"""
import math
import gdal
import ogr
from pyrasta.crs import srs_from
from pyrasta.utils import gdal_progress_bar
try:
from osgeo import gdal, ogr
except ImportError:
import gdal
import ogr
def _polygonize(raster, filename, band, layer_name,
field_name, ogr_driver, is_8_connected,
......
......@@ -8,9 +8,13 @@ from pyrasta.io_ import ESRI_DRIVER
from pyrasta.io_.files import ShapeTempFile
from pyrasta.tools import _gdal_temp_dataset, _return_raster
import gdal
from pyrasta.utils import gdal_progress_bar
try:
from osgeo import gdal
except ImportError:
import gdal
@_return_raster
def _rasterize(raster_class, out_file, gdal_driver, geodataframe,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment