예제 #1
0
class TestNoSindex:
    @pytest.mark.skipif(sindex.has_sindex(),
                        reason="Spatial index present, skipping")
    def test_no_sindex_installed(self):
        """Checks that an error is raised when no spatial index is present."""
        with pytest.raises(ImportError):
            sindex.get_sindex_class()

    @pytest.mark.skipif(
        compat.HAS_RTREE or not compat.HAS_PYGEOS,
        reason="rtree cannot be disabled via flags",
    )
    def test_no_sindex_active(self):
        """Checks that an error is given when rtree is not installed
        and compat.USE_PYGEOS is False.
        """
        state = compat.USE_PYGEOS  # try to save state
        compat.set_use_pygeos(False)
        with pytest.raises(ImportError):
            sindex.get_sindex_class()
        compat.set_use_pygeos(state)  # try to restore state
예제 #2
0
import sys

from shapely.geometry import Point, Polygon, box
from numpy.testing import assert_array_equal

import geopandas
from geopandas import _compat as compat
from geopandas import GeoDataFrame, GeoSeries, read_file, sindex

import pytest


@pytest.mark.skipif(sindex.has_sindex(),
                    reason="Spatial index present, skipping")
class TestNoSindex:
    def test_no_sindex(self):
        """Checks that a warning is given when no spatial index is present."""
        with pytest.warns():
            sindex.get_sindex_class()


@pytest.mark.skipif(sys.platform.startswith("win"), reason="fails on AppVeyor")
@pytest.mark.skipif(not sindex.has_sindex(),
                    reason="Spatial index absent, skipping")
class TestSeriesSindex:
    def test_empty_geoseries(self):

        assert GeoSeries().sindex is None

    def test_point(self):
        s = GeoSeries([Point(0, 0)])
예제 #3
0
from distutils.version import LooseVersion

import numpy as np
import pandas as pd

from shapely.geometry import Point, Polygon, GeometryCollection

import geopandas
from geopandas import GeoDataFrame, GeoSeries, read_file, sindex, sjoin

from pandas.testing import assert_frame_equal
import pytest

pytestmark = pytest.mark.skipif(not sindex.has_sindex(),
                                reason="sjoin requires spatial index")


@pytest.fixture()
def dfs(request):
    polys1 = GeoSeries([
        Polygon([(0, 0), (5, 0), (5, 5), (0, 5)]),
        Polygon([(5, 5), (6, 5), (6, 6), (5, 6)]),
        Polygon([(6, 0), (9, 0), (9, 3), (6, 3)]),
    ])

    polys2 = GeoSeries([
        Polygon([(1, 1), (4, 1), (4, 4), (1, 4)]),
        Polygon([(4, 4), (7, 4), (7, 7), (4, 7)]),
        Polygon([(7, 7), (10, 7), (10, 10), (7, 10)]),
    ])
예제 #4
0
from distutils.version import LooseVersion

import numpy as np
import pandas as pd

from shapely.geometry import Point, Polygon, GeometryCollection

import geopandas
from geopandas import GeoDataFrame, GeoSeries, read_file, sindex, sjoin

from pandas.testing import assert_frame_equal
import pytest


pytestmark = pytest.mark.skipif(
    not sindex.has_sindex(), reason="sjoin requires spatial index"
)


@pytest.fixture()
def dfs(request):
    polys1 = GeoSeries(
        [
            Polygon([(0, 0), (5, 0), (5, 5), (0, 5)]),
            Polygon([(5, 5), (6, 5), (6, 6), (5, 6)]),
            Polygon([(6, 0), (9, 0), (9, 3), (6, 3)]),
        ]
    )

    polys2 = GeoSeries(
        [