Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEA]: Support binary predicates with GeoSeries - shapely.geometry object #1316

Open
vboussange opened this issue Dec 27, 2023 · 7 comments
Open
Labels
External Issues filed by people outside the team feature request New feature or request Python Related to Python code

Comments

@vboussange
Copy link

vboussange commented Dec 27, 2023

Version

23.12.01

On which installation method(s) does this occur?

Conda

Describe the issue

Method within does not work as expected when used with a single polygon object.

Minimum reproducible example

import cuspatial
import geopandas
from shapely.geometry import Polygon, LineString, Poin

s = geopandas.GeoSeries(
    [
        Polygon([(0, 0), (2, 2), (0, 2)]),
        Polygon([(0, 0), (1, 2), (0, 2)]),
        LineString([(0, 0), (0, 2)]),
        Point(0, 1),
    ],
)

polygon = Polygon([(0, 0), (2, 2), (0, 2)])

s_cu = cuspatial.from_geopandas(s)

s.within(polygon) # works
s_cu.within(polygon) # errors

Relevant log output

`AttributeError: 'Polygon' object has no attribute 'column_type'`

Environment details

**git***
     commit c1494b6f5395629f8e62a5a5759400696b6bdbe5 (HEAD -> master, origin/master, origin/HEAD)
     Author: victorb <[email protected]>
     Date:   Wed Dec 27 11:47:32 2023 +0100
     
     calculating density works with cupsatial
     **git submodules***
     
     ***OS Information***
     DISTRIB_ID=Ubuntu
     DISTRIB_RELEASE=22.04
     DISTRIB_CODENAME=jammy
     DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"
     PRETTY_NAME="Ubuntu 22.04.3 LTS"
     NAME="Ubuntu"
     VERSION_ID="22.04"
     VERSION="22.04.3 LTS (Jammy Jellyfish)"
     VERSION_CODENAME=jammy
     ID=ubuntu
     ID_LIKE=debian
     HOME_URL="https://www.ubuntu.com/"
     SUPPORT_URL="https://help.ubuntu.com/"
     BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
     PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
     UBUNTU_CODENAME=jammy
     Linux sauron 5.15.0-91-generic #101-Ubuntu SMP Tue Nov 14 13:30:08 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
     
     ***GPU Information***
     Wed Dec 27 14:29:19 2023
     +---------------------------------------------------------------------------------------+
     | NVIDIA-SMI 535.129.03             Driver Version: 535.129.03   CUDA Version: 12.2     |
     |-----------------------------------------+----------------------+----------------------+
     | GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
     | Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
     |                                         |                      |               MIG M. |
     |=========================================+======================+======================|
     |   0  NVIDIA GeForce RTX 3090        Off | 00000000:42:00.0 Off |                  N/A |
     | 30%   36C    P0              91W / 350W |      2MiB / 24576MiB |      0%      Default |
     |                                         |                      |                  N/A |
     +-----------------------------------------+----------------------+----------------------+
     
     +---------------------------------------------------------------------------------------+
     | Processes:                                                                            |
     |  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
     |        ID   ID                                                             Usage      |
     |=======================================================================================|
     |  No running processes found                                                           |
     +---------------------------------------------------------------------------------------+
     
     ***CPU***
     Architecture:                       x86_64
     CPU op-mode(s):                     32-bit, 64-bit
     Address sizes:                      43 bits physical, 48 bits virtual
     Byte Order:                         Little Endian
     CPU(s):                             32
     On-line CPU(s) list:                0-31
     Vendor ID:                          AuthenticAMD
     Model name:                         AMD EPYC 7302P 16-Core Processor
     CPU family:                         23
     Model:                              49
     Thread(s) per core:                 2
     Core(s) per socket:                 16
     Socket(s):                          1
     Stepping:                           0
     Frequency boost:                    enabled
     CPU max MHz:                        3000.0000
     CPU min MHz:                        1500.0000
     BogoMIPS:                           5999.88
     Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip rdpid overflow_recov succor smca sme sev sev_es
     Virtualization:                     AMD-V
     L1d cache:                          512 KiB (16 instances)
     L1i cache:                          512 KiB (16 instances)
     L2 cache:                           8 MiB (16 instances)
     L3 cache:                           128 MiB (8 instances)
     NUMA node(s):                       4
     NUMA node0 CPU(s):                  0-3,16-19
     NUMA node1 CPU(s):                  4-7,20-23
     NUMA node2 CPU(s):                  8-11,24-27
     NUMA node3 CPU(s):                  12-15,28-31
     Vulnerability Gather data sampling: Not affected
     Vulnerability Itlb multihit:        Not affected
     Vulnerability L1tf:                 Not affected
     Vulnerability Mds:                  Not affected
     Vulnerability Meltdown:             Not affected
     Vulnerability Mmio stale data:      Not affected
     Vulnerability Retbleed:             Mitigation; untrained return thunk; SMT enabled with STIBP protection
     Vulnerability Spec rstack overflow: Mitigation; safe RET
     Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl and seccomp
     Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
     Vulnerability Spectre v2:           Mitigation; Retpolines, IBPB conditional, STIBP always-on, RSB filling, PBRSB-eIBRS Not affected
     Vulnerability Srbds:                Not affected
     Vulnerability Tsx async abort:      Not affected
     
     ***CMake***
     
     ***g++***
     /usr/bin/g++
     g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
     Copyright (C) 2021 Free Software Foundation, Inc.
     This is free software; see the source for copying conditions.  There is NO
     warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     
     
     ***nvcc***
     /home/boussang/SAR_modelling/python/.env/bin/nvcc
     nvcc: NVIDIA (R) Cuda compiler driver
     Copyright (c) 2005-2023 NVIDIA Corporation
     Built on Mon_Apr__3_17:16:06_PDT_2023
     Cuda compilation tools, release 12.1, V12.1.105
     Build cuda_12.1.r12.1/compiler.32688072_0
     
     ***Python***
     /home/boussang/SAR_modelling/python/.env/bin/python
     Python 3.9.18
     
     ***Environment Variables***
     PATH                            : /home/boussang/.vscode-server/bin/0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2/bin/remote-cli:/home/boussang/SAR_modelling/python/.env/bin:/home/boussang/miniforge3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
     LD_LIBRARY_PATH                 :
     NUMBAPRO_NVVM                   :
     NUMBAPRO_LIBDEVICE              :
     CONDA_PREFIX                    : /home/boussang/SAR_modelling/python/.env
     PYTHON_PATH                     :
     
     ***conda packages***
     /home/boussang/miniforge3/condabin/conda

     # packages in environment at /home/boussang/SAR_modelling/python/.env:
     #
     # Name                    Version                   Build  Channel
     _libgcc_mutex             0.1                 conda_forge    conda-forge
     _openmp_mutex             4.5                  2_kmp_llvm    conda-forge
     _py-xgboost-mutex         2.0                       gpu_0    conda-forge
     affine                    2.4.0              pyhd8ed1ab_0    conda-forge
     alsa-lib                  1.2.10               hd590300_0    conda-forge
     appdirs                   1.4.4                    pypi_0    pypi
     asttokens                 2.4.1              pyhd8ed1ab_0    conda-forge
     attr                      2.5.1                h166bdaf_1    conda-forge
     attrs                     23.1.0             pyh71513ae_1    conda-forge
     aws-c-auth                0.7.8                hcf8cf63_3    conda-forge
     aws-c-cal                 0.6.9                h5d48c4d_2    conda-forge
     aws-c-common              0.9.10               hd590300_0    conda-forge
     aws-c-compression         0.2.17               h7f92143_7    conda-forge
     aws-c-event-stream        0.3.2                h0bcb0bb_8    conda-forge
     aws-c-http                0.7.15               hd268abd_0    conda-forge
     aws-c-io                  0.13.36              hb3b01f7_3    conda-forge
     aws-c-mqtt                0.10.0               hbafccad_1    conda-forge
     aws-c-s3                  0.4.6                h47b1690_0    conda-forge
     aws-c-sdkutils            0.1.13               h7f92143_0    conda-forge
     aws-checksums             0.1.17               h7f92143_6    conda-forge
     aws-crt-cpp               0.25.0               hfa7cc67_4    conda-forge
     aws-sdk-cpp               1.11.210             h0853bfa_5    conda-forge
     azure-core-cpp            1.10.3               h91d86a7_0    conda-forge
     azure-storage-blobs-cpp   12.10.0              h00ab1b0_0    conda-forge
     azure-storage-common-cpp  12.5.0               hb858b4b_2    conda-forge
     blosc                     1.21.5               h0f2a231_0    conda-forge
     bokeh                     3.3.2              pyhd8ed1ab_0    conda-forge
     branca                    0.7.0              pyhd8ed1ab_1    conda-forge
     brotli                    1.1.0                hd590300_1    conda-forge
     brotli-bin                1.1.0                hd590300_1    conda-forge
     brotli-python             1.1.0            py39h3d6467e_1    conda-forge
     bzip2                     1.0.8                hd590300_5    conda-forge
     c-ares                    1.24.0               hd590300_0    conda-forge
     ca-certificates           2023.11.17           hbcca054_0    conda-forge
     cachetools                5.3.2              pyhd8ed1ab_0    conda-forge
     cairo                     1.18.0               h3faef2a_0    conda-forge
     cartopy                   0.22.0           py39hddac248_1    conda-forge
     cattrs                    23.2.3                   pypi_0    pypi
     certifi                   2023.11.17         pyhd8ed1ab_0    conda-forge
     cfitsio                   4.3.1                hbdc6101_0    conda-forge
     charset-normalizer        3.3.2              pyhd8ed1ab_0    conda-forge
     click                     8.1.7           unix_pyh707e725_0    conda-forge
     click-plugins             1.1.1                      py_0    conda-forge
     cligj                     0.7.2              pyhd8ed1ab_1    conda-forge
     cloudpickle               3.0.0              pyhd8ed1ab_0    conda-forge
     colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
     comm                      0.1.4              pyhd8ed1ab_0    conda-forge
     contourpy                 1.2.0            py39h7633fee_0    conda-forge
     cuda-cccl_linux-64        12.1.109             ha770c72_0    conda-forge
     cuda-cudart               12.1.105             hd3aeb46_0    conda-forge
     cuda-cudart-dev           12.1.105             hd3aeb46_0    conda-forge
     cuda-cudart-dev_linux-64  12.1.105             h59595ed_0    conda-forge
     cuda-cudart-static        12.1.105             hd3aeb46_0    conda-forge
     cuda-cudart-static_linux-64 12.1.105             h59595ed_0    conda-forge
     cuda-cudart_linux-64      12.1.105             h59595ed_0    conda-forge
     cuda-nvcc-dev_linux-64    12.1.105             ha770c72_0    conda-forge
     cuda-nvcc-impl            12.1.105             hd3aeb46_0    conda-forge
     cuda-nvcc-tools           12.1.105             hd3aeb46_0    conda-forge
     cuda-nvrtc                12.1.105             hd3aeb46_0    conda-forge
     cuda-nvtx                 12.1.105             h59595ed_0    conda-forge
     cuda-python               12.1.0           py39h44b3ebe_0    conda-forge
     cuda-version              12.1                 h1d6eff3_2    conda-forge
     cudf                      23.12.01        cuda12_py39_231208_g2ce46216b5_0    rapidsai
     cudnn                     8.8.0.121            h264754d_4    conda-forge
     cupy                      12.3.0           py39hc7c1505_0    conda-forge
     cuspatial                 23.12.01        cuda12_py39_231207_g16727064_0    rapidsai
     cycler                    0.12.1             pyhd8ed1ab_0    conda-forge
     cytoolz                   0.12.2           py39hd1e30aa_1    conda-forge
     dask                      2023.12.1          pyhd8ed1ab_0    conda-forge
     dask-core                 2023.12.1          pyhd8ed1ab_0    conda-forge
     dask-geopandas            0.3.1              pyhd8ed1ab_1    conda-forge
     dbus                      1.13.6               h5008d03_3    conda-forge
     debugpy                   1.8.0            py39h3d6467e_1    conda-forge
     decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
     distributed               2023.12.1          pyhd8ed1ab_0    conda-forge
     dlpack                    0.5                  h9c3ff4c_0    conda-forge
     exceptiongroup            1.2.0              pyhd8ed1ab_0    conda-forge
     executing                 2.0.1              pyhd8ed1ab_0    conda-forge
     expat                     2.5.0                hcb278e6_1    conda-forge
     fastrlock                 0.8.2            py39h3d6467e_2    conda-forge
     filelock                  3.13.1             pyhd8ed1ab_0    conda-forge
     fiona                     1.9.5            py39hcfcd403_2    conda-forge
     fmt                       9.1.0                h924138e_0    conda-forge
     folium                    0.15.1             pyhd8ed1ab_0    conda-forge
     font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
     font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
     font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
     font-ttf-ubuntu           0.83                 h77eed37_1    conda-forge
     fontconfig                2.14.2               h14ed4e7_0    conda-forge
     fonts-conda-ecosystem     1                             0    conda-forge
     fonts-conda-forge         1                             0    conda-forge
     fonttools                 4.47.0           py39hd1e30aa_0    conda-forge
     freetype                  2.12.1               h267a509_2    conda-forge
     freexl                    2.0.0                h743c826_0    conda-forge
     fsspec                    2023.12.2          pyhca7485f_0    conda-forge
     gdal                      3.8.2            py39h14df8fe_1    conda-forge
     geographiclib             1.52               pyhd8ed1ab_0    conda-forge
     geojson-rewind            1.1.0                    pypi_0    pypi
     geomet                    1.1.0                    pypi_0    pypi
     geopandas                 0.14.1             pyhd8ed1ab_0    conda-forge
     geopandas-base            0.14.1             pyha770c72_0    conda-forge
     geopy                     2.4.1              pyhd8ed1ab_0    conda-forge
     geos                      3.12.1               h59595ed_0    conda-forge
     geotiff                   1.7.1               h6b2125f_15    conda-forge
     gettext                   0.21.1               h27087fc_0    conda-forge
     gflags                    2.2.2             he1b5a44_1004    conda-forge
     giflib                    5.2.1                h0b41bf4_3    conda-forge
     glib                      2.78.3               hfc55251_0    conda-forge
     glib-tools                2.78.3               hfc55251_0    conda-forge
     glog                      0.6.0                h6f12383_0    conda-forge
     gmock                     1.14.0               ha770c72_1    conda-forge
     gmp                       6.3.0                h59595ed_0    conda-forge
     gmpy2                     2.1.2            py39h376b7d2_1    conda-forge
     graphite2                 1.3.13            h58526e2_1001    conda-forge
     gst-plugins-base          1.22.8               h8e1006c_0    conda-forge
     gstreamer                 1.22.8               h98fc4e7_0    conda-forge
     gtest                     1.14.0               h00ab1b0_1    conda-forge
     harfbuzz                  8.3.0                h3d44ed6_0    conda-forge
     hdf4                      4.2.15               h2a13503_7    conda-forge
     hdf5                      1.14.3          nompi_h4f84152_100    conda-forge
     icu                       73.2                 h59595ed_0    conda-forge
     idna                      3.6                pyhd8ed1ab_0    conda-forge
     importlib-metadata        7.0.1              pyha770c72_0    conda-forge
     importlib-resources       6.1.1              pyhd8ed1ab_0    conda-forge
     importlib_metadata        7.0.1                hd8ed1ab_0    conda-forge
     importlib_resources       6.1.1              pyhd8ed1ab_0    conda-forge
     ipykernel                 6.26.0             pyhf8b6a83_0    conda-forge
     ipython                   8.18.1             pyh707e725_3    conda-forge
     jedi                      0.19.1             pyhd8ed1ab_0    conda-forge
     jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
     joblib                    1.3.2              pyhd8ed1ab_0    conda-forge
     json-c                    0.17                 h7ab15ed_0    conda-forge
     jupyter_client            8.6.0              pyhd8ed1ab_0    conda-forge
     jupyter_core              5.5.1            py39hf3d152e_0    conda-forge
     kealib                    1.5.3                h2f55d51_0    conda-forge
     keyutils                  1.6.1                h166bdaf_0    conda-forge
     kiwisolver                1.4.5            py39h7633fee_1    conda-forge
     krb5                      1.21.2               h659d440_0    conda-forge
     lame                      3.100             h166bdaf_1003    conda-forge
     lcms2                     2.16                 hb7c19ff_0    conda-forge
     ld_impl_linux-64          2.40                 h41732ed_0    conda-forge
     lerc                      4.0.0                h27087fc_0    conda-forge
     libabseil                 20230802.1      cxx17_h59595ed_0    conda-forge
     libaec                    1.1.2                h59595ed_1    conda-forge
     libarchive                3.7.2                h2aa1ff5_1    conda-forge
     libarrow                  14.0.2           hfb4d3a9_0_cpu    conda-forge
     libarrow-acero            14.0.2           h59595ed_0_cpu    conda-forge
     libarrow-dataset          14.0.2           h59595ed_0_cpu    conda-forge
     libarrow-flight           14.0.2           h120cb0d_0_cpu    conda-forge
     libarrow-flight-sql       14.0.2           h61ff412_0_cpu    conda-forge
     libarrow-gandiva          14.0.2           hacb8726_0_cpu    conda-forge
     libarrow-substrait        14.0.2           h61ff412_0_cpu    conda-forge
     libblas                   3.9.0           20_linux64_openblas    conda-forge
     libboost-headers          1.84.0               ha770c72_0    conda-forge
     libbrotlicommon           1.1.0                hd590300_1    conda-forge
     libbrotlidec              1.1.0                hd590300_1    conda-forge
     libbrotlienc              1.1.0                hd590300_1    conda-forge
     libcap                    2.69                 h0f662aa_0    conda-forge
     libcblas                  3.9.0           20_linux64_openblas    conda-forge
     libclang                  15.0.7          default_hb11cfb5_4    conda-forge
     libclang13                15.0.7          default_ha2b6cf4_4    conda-forge
     libcrc32c                 1.1.2                h9c3ff4c_0    conda-forge
     libcublas                 12.1.3.1             hd3aeb46_0    conda-forge
     libcudf                   23.12.01        cuda12_231208_g2ce46216b5_0    rapidsai
     libcufft                  11.0.2.54            hd3aeb46_0    conda-forge
     libcufile                 1.6.1.9              hd3aeb46_0    conda-forge
     libcufile-dev             1.6.1.9              hd3aeb46_0    conda-forge
     libcups                   2.3.3                h4637d8d_4    conda-forge
     libcurand                 10.3.2.106           hd3aeb46_0    conda-forge
     libcurl                   8.5.0                hca28451_0    conda-forge
     libcusolver               11.4.5.107           hd3aeb46_0    conda-forge
     libcusparse               12.1.0.106           hd3aeb46_0    conda-forge
     libcuspatial              23.12.01        cuda12_231207_g16727064_0    rapidsai
     libdeflate                1.19                 hd590300_0    conda-forge
     libedit                   3.1.20191231         he28a2e2_2    conda-forge
     libev                     4.33                 hd590300_2    conda-forge
     libevent                  2.1.12               hf998b51_1    conda-forge
     libexpat                  2.5.0                hcb278e6_1    conda-forge
     libffi                    3.4.2                h7f98852_5    conda-forge
     libflac                   1.4.3                h59595ed_0    conda-forge
     libgcc-ng                 13.2.0               h807b86a_3    conda-forge
     libgcrypt                 1.10.3               hd590300_0    conda-forge
     libgdal                   3.8.2                hcd1fc54_1    conda-forge
     libgfortran-ng            13.2.0               h69a702a_3    conda-forge
     libgfortran5              13.2.0               ha4646dd_3    conda-forge
     libglib                   2.78.3               h783c2da_0    conda-forge
     libgoogle-cloud           2.12.0               h5206363_4    conda-forge
     libgpg-error              1.47                 h71f35ed_0    conda-forge
     libgrpc                   1.59.3               hd6c4280_0    conda-forge
     libiconv                  1.17                 hd590300_2    conda-forge
     libjpeg-turbo             3.0.0                hd590300_1    conda-forge
     libkml                    1.3.0             h01aab08_1018    conda-forge
     libkvikio                 23.12.00        cuda12_231206_gf90bfbe_0    rapidsai
     liblapack                 3.9.0           20_linux64_openblas    conda-forge
     libllvm14                 14.0.6               hcd5def8_4    conda-forge
     libllvm15                 15.0.7               hb3ce162_4    conda-forge
     libmagma                  2.7.2                h173bb3b_2    conda-forge
     libmagma_sparse           2.7.2                h173bb3b_2    conda-forge
     libnetcdf                 4.9.2           nompi_h9612171_113    conda-forge
     libnghttp2                1.58.0               h47da74e_1    conda-forge
     libnl                     3.9.0                hd590300_0    conda-forge
     libnsl                    2.0.1                hd590300_0    conda-forge
     libnuma                   2.0.16               h0b41bf4_1    conda-forge
     libnvjitlink              12.1.105             hd3aeb46_0    conda-forge
     libogg                    1.3.4                h7f98852_1    conda-forge
     libopenblas               0.3.25          pthreads_h413a1c8_0    conda-forge
     libopus                   1.3.1                h7f98852_1    conda-forge
     libparquet                14.0.2           h352af49_0_cpu    conda-forge
     libpng                    1.6.39               h753d276_0    conda-forge
     libpq                     16.1                 h33b98f1_7    conda-forge
     libprotobuf               4.24.4               hf27288f_0    conda-forge
     libre2-11                 2023.06.02           h7a70373_0    conda-forge
     librmm                    23.12.00        cuda12_231206_g2db5cbb3_0    rapidsai
     librttopo                 1.1.0               h8917695_15    conda-forge
     libsndfile                1.2.2                hc60ed4a_1    conda-forge
     libsodium                 1.0.18               h36c2ea0_1    conda-forge
     libspatialindex           1.9.3                h9c3ff4c_4    conda-forge
     libspatialite             5.1.0                h7bd4643_4    conda-forge
     libsqlite                 3.44.2               h2797004_0    conda-forge
     libssh2                   1.11.0               h0841786_0    conda-forge
     libstdcxx-ng              13.2.0               h7e041cc_3    conda-forge
     libsystemd0               255                  h3516f8a_0    conda-forge
     libthrift                 0.19.0               hb90f79a_1    conda-forge
     libtiff                   4.6.0                ha9c0a0a_2    conda-forge
     libutf8proc               2.8.0                h166bdaf_0    conda-forge
     libuuid                   2.38.1               h0b41bf4_0    conda-forge
     libuv                     1.46.0               hd590300_0    conda-forge
     libvorbis                 1.3.7                h9c3ff4c_0    conda-forge
     libwebp-base              1.3.2                hd590300_0    conda-forge
     libxcb                    1.15                 h0b41bf4_0    conda-forge
     libxcrypt                 4.4.36               hd590300_1    conda-forge
     libxgboost                2.0.3           cuda120_h75debf4_0    conda-forge
     libxkbcommon              1.6.0                hd429924_1    conda-forge
     libxml2                   2.12.3               h232c23b_0    conda-forge
     libzip                    1.10.1               h2629f0a_3    conda-forge
     libzlib                   1.2.13               hd590300_5    conda-forge
     llvm-openmp               17.0.6               h4dfa4b3_0    conda-forge
     llvmlite                  0.40.1           py39h174d805_0    conda-forge
     locket                    1.0.0              pyhd8ed1ab_0    conda-forge
     lz4                       4.3.2            py39h79d96da_1    conda-forge
     lz4-c                     1.9.4                hcb278e6_0    conda-forge
     lzo                       2.10              h516909a_1000    conda-forge
     magma                     2.7.2                h51420fd_2    conda-forge
     mapclassify               2.6.1              pyhd8ed1ab_0    conda-forge
     markdown-it-py            3.0.0              pyhd8ed1ab_0    conda-forge
     markupsafe                2.1.3            py39hd1e30aa_1    conda-forge
     matplotlib                3.8.2            py39hf3d152e_0    conda-forge
     matplotlib-base           3.8.2            py39he9076e7_0    conda-forge
     matplotlib-inline         0.1.6              pyhd8ed1ab_0    conda-forge
     mdurl                     0.1.0              pyhd8ed1ab_0    conda-forge
     minizip                   4.0.3                h0ab5242_0    conda-forge
     mkl                       2022.2.1         h84fe81f_16997    conda-forge
     mpc                       1.3.1                hfe3b2da_0    conda-forge
     mpfr                      4.2.1                h9458935_0    conda-forge
     mpg123                    1.32.3               h59595ed_0    conda-forge
     mpmath                    1.3.0              pyhd8ed1ab_0    conda-forge
     msgpack-python            1.0.7            py39h7633fee_0    conda-forge
     munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
     mysql-common              8.0.33               hf1915f5_6    conda-forge
     mysql-libs                8.0.33               hca2cd23_6    conda-forge
     nccl                      2.19.4.1             h3a97aeb_0    conda-forge
     ncurses                   6.4                  h59595ed_2    conda-forge
     nest-asyncio              1.5.8              pyhd8ed1ab_0    conda-forge
     networkx                  3.2.1              pyhd8ed1ab_0    conda-forge
     nspr                      4.35                 h27087fc_0    conda-forge
     nss                       3.96                 h1d7d5a4_0    conda-forge
     numba                     0.57.1           py39hb75a051_0    conda-forge
     numpy                     1.24.4           py39h6183b62_0    conda-forge
     nvcomp                    3.0.4                h10b603f_1    conda-forge
     nvtx                      0.2.8            py39hd1e30aa_1    conda-forge
     openjpeg                  2.5.0                h488ebb8_3    conda-forge
     openssl                   3.2.0                hd590300_1    conda-forge
     orc                       1.9.2                h4b38347_0    conda-forge
     packaging                 23.2               pyhd8ed1ab_0    conda-forge
     pandas                    1.5.3            py39h2ad29b5_1    conda-forge
     parso                     0.8.3              pyhd8ed1ab_0    conda-forge
     partd                     1.4.1              pyhd8ed1ab_0    conda-forge
     pcre2                     10.42                hcad00b1_0    conda-forge
     pexpect                   4.8.0              pyh1a96a4e_2    conda-forge
     pickleshare               0.7.5                   py_1003    conda-forge
     pillow                    10.1.0           py39had0adad_0    conda-forge
     pip                       23.3.2             pyhd8ed1ab_0    conda-forge
     pixman                    0.42.2               h59595ed_0    conda-forge
     platformdirs              4.1.0              pyhd8ed1ab_0    conda-forge
     ply                       3.11                       py_1    conda-forge
     poppler                   23.12.0              h590f24d_0    conda-forge
     poppler-data              0.4.12               hd8ed1ab_0    conda-forge
     postgresql                16.1                 h7387d8b_7    conda-forge
     proj                      9.3.1                h1d62c97_0    conda-forge
     prompt-toolkit            3.0.42             pyha770c72_0    conda-forge
     protobuf                  4.24.4           py39h60f6b12_0    conda-forge
     psutil                    5.9.7            py39hd1e30aa_0    conda-forge
     pthread-stubs             0.4               h36c2ea0_1001    conda-forge
     ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
     pulseaudio-client         16.1                 hb77b528_5    conda-forge
     pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
     py-xgboost                2.0.3           cuda120_py39h206be00_0    conda-forge
     pyarrow                   14.0.2          py39h6925388_0_cpu    conda-forge
     pyarrow-hotfix            0.6                pyhd8ed1ab_0    conda-forge
     pygbif                    0.6.3                    pypi_0    pypi
     pygments                  2.17.2             pyhd8ed1ab_0    conda-forge
     pyparsing                 3.1.1              pyhd8ed1ab_0    conda-forge
     pyproj                    3.6.1            py39h15b0fa6_5    conda-forge
     pyqt                      5.15.9           py39h52134e7_5    conda-forge
     pyqt5-sip                 12.12.2          py39h3d6467e_5    conda-forge
     pyshp                     2.3.1              pyhd8ed1ab_0    conda-forge
     pysocks                   1.7.1              pyha2e5f31_6    conda-forge
     python                    3.9.18          h0755675_1_cpython    conda-forge
     python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
     python-tzdata             2023.3             pyhd8ed1ab_0    conda-forge
     python_abi                3.9                      4_cp39    conda-forge
     pytorch                   2.1.0           cuda120py39hf872c3d_301    conda-forge
     pytz                      2023.3.post1       pyhd8ed1ab_0    conda-forge
     pyyaml                    6.0.1            py39hd1e30aa_1    conda-forge
     pyzmq                     25.1.2           py39h8c080ef_0    conda-forge
     qt-main                   5.15.8              h450f30e_18    conda-forge
     rasterio                  1.3.9            py39hb497ac4_2    conda-forge
     rdma-core                 49.0                 hd3aeb46_2    conda-forge
     re2                       2023.06.02           h2873b5e_0    conda-forge
     readline                  8.2                  h8228510_1    conda-forge
     requests                  2.31.0             pyhd8ed1ab_0    conda-forge
     requests-cache            1.1.1                    pypi_0    pypi
     rich                      13.7.0             pyhd8ed1ab_0    conda-forge
     rioxarray                 0.15.0             pyhd8ed1ab_0    conda-forge
     rmm                       23.12.00        cuda12_py39_231206_g2db5cbb3_0    rapidsai
     rtree                     1.1.0            py39hb102c33_0    conda-forge
     s2n                       1.4.1                h06160fa_0    conda-forge
     scikit-learn              1.3.2            py39ha22ef79_2    conda-forge
     scipy                     1.11.4           py39h474f0d3_0    conda-forge
     setuptools                68.2.2             pyhd8ed1ab_0    conda-forge
     shapely                   2.0.2            py39h6404dd3_1    conda-forge
     sip                       6.7.12           py39h3d6467e_0    conda-forge
     six                       1.16.0             pyh6c4a22f_0    conda-forge
     sleef                     3.5.1                h9b69904_2    conda-forge
     snappy                    1.1.10               h9fff704_0    conda-forge
     snuggs                    1.4.7                      py_0    conda-forge
     sortedcontainers          2.4.0              pyhd8ed1ab_0    conda-forge
     spdlog                    1.11.0               h9b3ece8_1    conda-forge
     sqlite                    3.44.2               h2c6b66d_0    conda-forge
     src                       0.0.0                     dev_0    <develop>
     stack_data                0.6.2              pyhd8ed1ab_0    conda-forge
     sympy                     1.12            pypyh9d50eac_103    conda-forge
     tbb                       2021.7.0             h924138e_0    conda-forge
     tblib                     3.0.0              pyhd8ed1ab_0    conda-forge
     threadpoolctl             3.2.0              pyha21a80b_0    conda-forge
     tiledb                    2.19.0               hc1131af_0    conda-forge
     tk                        8.6.13          noxft_h4845f30_101    conda-forge
     toml                      0.10.2             pyhd8ed1ab_0    conda-forge
     tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
     toolz                     0.12.0             pyhd8ed1ab_0    conda-forge
     torchvision               0.16.1          cuda120py39h383dd1f_2    conda-forge
     tornado                   6.3.3            py39hd1e30aa_1    conda-forge
     tqdm                      4.66.1             pyhd8ed1ab_0    conda-forge
     traitlets                 5.14.0             pyhd8ed1ab_0    conda-forge
     typing_extensions         4.9.0              pyha770c72_0    conda-forge
     tzcode                    2023d                h3f72095_0    conda-forge
     tzdata                    2023d                h0c530f3_0    conda-forge
     ucx                       1.15.0               h6d2d1ec_2    conda-forge
     unicodedata2              15.1.0           py39hd1e30aa_0    conda-forge
     uriparser                 0.9.7                hcb278e6_1    conda-forge
     url-normalize             1.4.3                    pypi_0    pypi
     urllib3                   2.1.0              pyhd8ed1ab_0    conda-forge
     wcwidth                   0.2.12             pyhd8ed1ab_0    conda-forge
     wheel                     0.42.0             pyhd8ed1ab_0    conda-forge
     xarray                    2023.12.0          pyhd8ed1ab_0    conda-forge
     xcb-util                  0.4.0                hd590300_1    conda-forge
     xcb-util-image            0.4.0                h8ee46fc_1    conda-forge
     xcb-util-keysyms          0.4.0                h8ee46fc_1    conda-forge
     xcb-util-renderutil       0.3.9                hd590300_1    conda-forge
     xcb-util-wm               0.4.1                h8ee46fc_1    conda-forge
     xerces-c                  3.2.5                hac6953d_0    conda-forge
     xgboost                   2.0.3           cuda120_py39h206be00_0    conda-forge
     xkeyboard-config          2.40                 hd590300_0    conda-forge
     xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
     xorg-libice               1.1.1                hd590300_0    conda-forge
     xorg-libsm                1.2.4                h7391055_0    conda-forge
     xorg-libx11               1.8.7                h8ee46fc_0    conda-forge
     xorg-libxau               1.0.11               hd590300_0    conda-forge
     xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
     xorg-libxext              1.3.4                h0b41bf4_2    conda-forge
     xorg-libxrender           0.9.11               hd590300_0    conda-forge
     xorg-renderproto          0.11.1            h7f98852_1002    conda-forge
     xorg-xextproto            7.3.0             h0b41bf4_1003    conda-forge
     xorg-xf86vidmodeproto     2.3.1             h7f98852_1002    conda-forge
     xorg-xproto               7.0.31            h7f98852_1007    conda-forge
     xyzservices               2023.10.1          pyhd8ed1ab_0    conda-forge
     xz                        5.2.6                h166bdaf_0    conda-forge
     yaml                      0.2.5                h7f98852_2    conda-forge
     zeromq                    4.3.5                h59595ed_0    conda-forge
     zict                      3.0.0              pyhd8ed1ab_0    conda-forge
     zipp                      3.17.0             pyhd8ed1ab_0    conda-forge
     zlib                      1.2.13               hd590300_5    conda-forge
     zstd                      1.5.5                hfc55251_0    conda-forge

Other/Misc.

No response

@vboussange vboussange added the bug Something isn't working label Dec 27, 2023
@GPUtester GPUtester added Needs Triage Need team to review and classify External Issues filed by people outside the team labels Dec 27, 2023
@GPUtester
Copy link
Contributor

Hi @vboussange!

Thanks for submitting this issue - our team has been notified and we'll get back to you as soon as we can!
In the mean time, feel free to add any relevant information to this issue.

@isVoid isVoid added Python Related to Python code and removed Needs Triage Need team to review and classify labels Dec 28, 2023
@isVoid
Copy link
Contributor

isVoid commented Dec 29, 2023

Hi @vboussange , thank you for making this issue! Per the documentation of GeoSeries.within, other argument currently only supports GeoSeries type input. Therefore you can slightly modify your code to make polygon a GeoSeries.

polys = cuspatial.GeoSeries([polygon] * len(s))
s_cu = cuspatial.from_geopandas(s)

However, this doesn't get you there yet. cuSpatial also has a limitation of only supporting binary predicates between two "single geometry type" geoseries for the moment. s, in the above code, is considered a mixed type geoseries. You could isolate the objects from the geoseries by its type, then call .within for each of them. Combining the two suggestions above, we now have:

import cudf
import cuspatial
from cuspatial.core._column.geometa import Feature_Enum

import geopandas
from shapely.geometry import Polygon, LineString, Point


def extract_single_geometry_from_series(
        s: cuspatial.GeoSeries,
        ty: cuspatial.core._column.geometa.Feature_Enum
):
    """Extract objects of type `ty` from GeoSeries `s`."""
    types = s._column._meta.input_types
    ilocs = cudf.Series(cudf.core.column.arange(len(types)))
    df = cudf.DataFrame(data={"types": types, "ilocs": ilocs})
    selected = df[df.types == ty.value].ilocs

    return s.iloc[selected]

s = geopandas.GeoSeries(
    [
        Polygon([(0, 0), (2, 2), (0, 2)]),
        Polygon([(0, 0), (1, 2), (0, 2)]),
        LineString([(0, 0), (0, 2)]),
        Point(0, 1),
    ],
)

polygon = Polygon([(0, 0), (2, 2), (0, 2)])

s_cu = cuspatial.from_geopandas(s)

tys = [Feature_Enum.POLYGON, Feature_Enum.LINESTRING, Feature_Enum.POINT]
partials = []
for ty in tys:
    ss_cu = extract_single_geometry_from_series(s_cu, ty)
    # Caching the index of the single type objects
    idx = ss_cu.index
    ss_cu = ss_cu.reset_index(drop=True)
    polys = cuspatial.GeoSeries([polygon] * len(ss_cu))
    # Compute within of single type geoseries
    partial = ss_cu.within(polys)
    # Restore index and cache partial results
    partial.index = idx
    partials.append(partial)

# Combine all results.
result = cudf.concat(partials).sort_index()
print(result)

Output:

0     True
1     True
2    False
3    False
dtype: bool

Please beware that this code will behave significantly slower than GeoPandas due to multiple kernels are launched on a small number of data. The kernel launching overhead dominates the latency. However, if you have a very large dataset, you could benefit from compute speedup.

@isVoid isVoid changed the title [BUG]: within not working for single polygon [FEA]: Support binary predicates with GeoSeries - shapely.geometry object Dec 29, 2023
@isVoid isVoid added feature request New feature or request and removed bug Something isn't working labels Dec 29, 2023
@vboussange
Copy link
Author

Hey there, thanks a lot for the explanation and the workaround.

For other cuspatial newcomers like me, I found out that the method cuspatial.point_in_polygon is what I was eventually looking for:

points = geopandas.GeoSeries([Point(0,1), Point(2,1), Point(4,2)])
polygons = geopandas.GeoSeries([Polygon([(0, 0), (2, 2), (0, 2)]), Polygon([(0, 0), (1, 2), (0, 2)])])

points_cu = cuspatial.from_geopandas(points)
polygons_cu = cuspatial.from_geopandas(polygons)

cuspatial.point_in_polygon(points_cu, polygons_cu)

output

       0      1
0  False  False
1  False  False
2  False  False

@isVoid
Copy link
Contributor

isVoid commented Jan 2, 2024

Cool! Note that point_in_polygon is an all-to-all PiP test function. The result you got is a 3x2 matrix, corresponding to 3 input points and 2 input polygons. As your example shows, it is also boundary excluding.

@harrism
Copy link
Member

harrism commented Jan 8, 2024

@isVoid should we close this now, or keep it open?

@isVoid
Copy link
Contributor

isVoid commented Jan 11, 2024

I would like to keep it open as a feature request issue to support geoseries - shapely.geometry object for binary predicates.

@thomcom
Copy link
Contributor

thomcom commented Jan 11, 2024

It should be an easy addition for short-term support - a single shapely geometry object can be placed in a GeoSeries and run as such.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Issues filed by people outside the team feature request New feature or request Python Related to Python code
Projects
Status: Todo
Development

No branches or pull requests

5 participants