1

Given a dataset of geometries (shapes.geojson) and a dataset of points (poi.geojson), I would expect that all geometries visibly intersecting with the points in the below plot would be returned when performing an intersection with GeoPandas’ GeoSeries’ intersects method.

enter image description here

ax = shapes.plot(color='b')
poi.plot(ax=ax, color='r')

But, when the action is performed, the below two geometries are the only two returned. Plotting the poi.geojson in red shows where the other missing geometries might have been returned.

enter image description here

ax = shapes[shapes.intersects(poi)].plot(color='b')
poi.plot(ax=ax, color='r')

My hunch was that there was something irregular with the data that was causing this but my reviews have come up dry.

Full datasets available as in this Gist (using these will replicate the plots).

Example subset to be kept here, that will also reproduce the issue:

POI:

['POINT (-75.742553 39.206201)',
 'POINT (-75.74302 39.20764)',
 'POINT (-75.70948 39.19225)',
 'POINT (-75.74267 39.19168)',
 'POINT (-75.74307 39.20648)',
 'POINT (-75.7098 39.19458)',
 'POINT (-75.74302 39.20764)',
 'POINT (-75.742344 39.202771)',
 'POINT (-75.74335000000001 39.20829)',
 'POINT (-75.72824 39.20797)',
 'POINT (-75.73072019999999 39.1857066)',
 'POINT (-75.73072019999999 39.1857066)',
 'POINT (-75.72963 39.18498)',
 'POINT (-75.71019 39.19135)',
 'POINT (-75.72824 39.20797)',
 'POINT (-75.710331 39.193604)',
 'POINT (-75.74302 39.20764)',
 'POINT (-75.730403 39.185359)',
 'POINT (-75.734275 39.210892)',
 'POINT (-75.73140100000001 39.1848839)',
 'POINT (-75.723707 39.189565)',
 'POINT (-75.734275 39.210892)']

Shapes:

['POLYGON ((-75.73580200000001 39.188298, -75.739127 39.186513, -75.739569 39.186804, -75.73967 39.186871, -75.740713 39.187578, -75.740769 39.18763, -75.740881 39.187736, -75.741124 39.187968, -75.74119399999999 39.188034, -75.7414 39.188331, -75.741562 39.18855, -75.741699 39.188767, -75.74171 39.188788, -75.74186899999999 39.189086, -75.742036 39.189502, -75.74259600000001 39.190997, -75.74296 39.191968, -75.744315 39.195443, -75.744816 39.196717, -75.745565 39.198621, -75.744911 39.198673, -75.74426 39.198725, -75.74408699999999 39.198854, -75.744304 39.199928, -75.744435 39.200571, -75.744246 39.200598, -75.74408200000001 39.200623, -75.74389600000001 39.200652, -75.74368200000001 39.200685, -75.743495 39.200715, -75.74284900000001 39.200772, -75.742559 39.200794, -75.742497 39.200799, -75.741827 39.200923, -75.741219 39.201056, -75.740942 39.201121, -75.740661 39.201187, -75.740301 39.201277, -75.73999999999999 39.201345, -75.739817 39.201417, -75.73978700000001 39.20143, -75.739559 39.201515, -75.739278 39.201647, -75.738964 39.201805, -75.73882399999999 39.201595, -75.738612 39.201386, -75.73857700000001 39.20132, -75.738563 39.20115, -75.73871800000001 39.200853, -75.738732 39.200793, -75.738739 39.200617, -75.738534 39.200364, -75.738011 39.199985, -75.737891 39.199887, -75.73780600000001 39.199744, -75.737792 39.199672, -75.73778 39.199539, -75.73777800000001 39.199513, -75.737848 39.198832, -75.73786800000001 39.198162, -75.738073 39.197722, -75.738044 39.197179, -75.738058 39.197107, -75.73820600000001 39.19686, -75.738277 39.196563, -75.738411 39.196311, -75.73846 39.196014, -75.738438 39.195794, -75.738283 39.195553, -75.737605 39.194932, -75.737442 39.19468, -75.73675 39.19396, -75.73645999999999 39.193719, -75.736439 39.193433, -75.73640399999999 39.193334, -75.73621300000001 39.193115, -75.736164 39.192961, -75.73621300000001 39.192862, -75.736474 39.192648, -75.73648799999999 39.192626, -75.73649500000001 39.192598, -75.736431 39.192477, -75.736375 39.192444, -75.736283 39.192412, -75.73612799999999 39.192412, -75.736093 39.192415, -75.736008 39.192423, -75.735958 39.192406, -75.735845 39.19234, -75.735789 39.192296, -75.735506 39.191989, -75.73496299999999 39.191605, -75.73487799999999 39.191511, -75.734842 39.191412, -75.734835 39.191357, -75.73487799999999 39.191099, -75.73480000000001 39.190951, -75.73465899999999 39.190885, -75.734087 39.190858, -75.73369099999999 39.190836, -75.733501 39.190798, -75.733367 39.190759, -75.73333100000001 39.190721, -75.733204 39.190435, -75.733119 39.190342, -75.732992 39.190298, -75.73239 39.19013, -75.73580200000001 39.188298))',
 'POLYGON ((-75.73577400000001 39.184377, -75.73653400000001 39.184871, -75.737371 39.185415, -75.73795 39.185738, -75.73814400000001 39.185866, -75.739127 39.186513, -75.73580200000001 39.188298, -75.73239 39.19013, -75.73304400000001 39.190669, -75.73061800000001 39.192283, -75.729434 39.190607, -75.729325 39.190206, -75.729044 39.188818, -75.72897500000001 39.188762, -75.72860799999999 39.188548, -75.728544 39.188498, -75.72846 39.188405, -75.728156 39.187883, -75.72799999999999 39.187471, -75.727947 39.187318, -75.729714 39.187132, -75.730301 39.187031, -75.730345 39.187014, -75.730417 39.186987, -75.730497 39.186948, -75.73055600000001 39.186905, -75.730593 39.186845, -75.730626 39.186615, -75.730704 39.185886, -75.73074200000001 39.185542, -75.730752 39.185232, -75.730773 39.184589, -75.730958 39.18455, -75.731129 39.184523, -75.731855 39.184409, -75.73212100000001 39.184353, -75.73220000000001 39.184338, -75.732337 39.184314, -75.732555 39.184264, -75.73286400000001 39.18418, -75.73287500000001 39.184178, -75.73299 39.184125, -75.733159 39.18404, -75.733276 39.183956, -75.733452 39.18385, -75.733614 39.183739, -75.733684 39.183682, -75.733767 39.183616, -75.73393900000001 39.183486, -75.73397900000001 39.183454, -75.73410199999999 39.183361, -75.734144 39.18333, -75.73428199999999 39.183408, -75.7355 39.184199, -75.73577400000001 39.184377))',
 'POLYGON ((-75.718181 39.190346, -75.718226 39.190534, -75.718594 39.191852, -75.718643 39.191923, -75.718813 39.192033, -75.719173 39.192094, -75.71954700000001 39.192192, -75.71987900000001 39.192352, -75.72014 39.192582, -75.720203 39.192675, -75.72050299999999 39.193205, -75.72057100000001 39.193324, -75.720839 39.193593, -75.72156699999999 39.194389, -75.72209599999999 39.194987, -75.722146 39.195059, -75.72248500000001 39.195767, -75.722718 39.196174, -75.72287300000001 39.1963, -75.70958899999999 39.191293, -75.709891 39.191258, -75.71025400000001 39.191218, -75.710802 39.191174, -75.711106 39.19115, -75.711218 39.191141, -75.71252200000001 39.191001, -75.713138 39.190936, -75.714904 39.190734, -75.716528 39.190561, -75.716768 39.19053, -75.718121 39.190359, -75.718181 39.190346))',
 'POLYGON ((-75.72287300000001 39.1963, -75.722718 39.196174, -75.72248500000001 39.195767, -75.722146 39.195059, -75.72209599999999 39.194987, -75.72156699999999 39.194389, -75.720839 39.193593, -75.72057100000001 39.193324, -75.72050299999999 39.193205, -75.720203 39.192675, -75.72014 39.192582, -75.71987900000001 39.192352, -75.71954700000001 39.192192, -75.719173 39.192094, -75.718813 39.192033, -75.718643 39.191923, -75.718594 39.191852, -75.718226 39.190534, -75.718181 39.190346, -75.718366 39.190306, -75.71871299999999 39.190234, -75.7189 39.190178, -75.718919 39.190171, -75.719098 39.190107, -75.719134 39.190093, -75.719453 39.189928, -75.719824 39.189698, -75.721204 39.188845, -75.72194399999999 39.18837, -75.72201099999999 39.188328, -75.72264199999999 39.187913, -75.722936 39.187716, -75.72297500000001 39.187691, -75.72321599999999 39.187523, -75.72342399999999 39.187344, -75.72358 39.18719, -75.72375099999999 39.187038, -75.724017 39.186804, -75.724116 39.186717, -75.72425800000001 39.186605, -75.72430199999999 39.18657, -75.72447 39.186444, -75.724701 39.186333, -75.72499500000001 39.186194, -75.725694 39.185899, -75.72673 39.185461, -75.726848 39.18543, -75.72701499999999 39.185373, -75.727126 39.185336, -75.727362 39.185264, -75.72775300000001 39.185157, -75.727818 39.185143, -75.727639 39.185801, -75.727738 39.186219, -75.727788 39.186362, -75.727767 39.186708, -75.72780899999999 39.186922, -75.727859 39.187065, -75.727947 39.187318, -75.72799999999999 39.187471, -75.728156 39.187883, -75.72846 39.188405, -75.728544 39.188498, -75.72860799999999 39.188548, -75.72897500000001 39.188762, -75.729044 39.188818, -75.729325 39.190206, -75.729434 39.190607, -75.73061800000001 39.192283, -75.73304400000001 39.190669, -75.73239 39.19013, -75.732992 39.190298, -75.733119 39.190342, -75.733204 39.190435, -75.73333100000001 39.190721, -75.733367 39.190759, -75.733501 39.190798, -75.73369099999999 39.190836, -75.734087 39.190858, -75.73465899999999 39.190885, -75.73480000000001 39.190951, -75.73487799999999 39.191099, -75.734835 39.191357, -75.734842 39.191412, -75.73487799999999 39.191511, -75.73496299999999 39.191605, -75.735506 39.191989, -75.735789 39.192296, -75.735845 39.19234, -75.735958 39.192406, -75.736008 39.192423, -75.736093 39.192415, -75.73612799999999 39.192412, -75.736283 39.192412, -75.736375 39.192444, -75.736431 39.192477, -75.73649500000001 39.192598, -75.73648799999999 39.192626, -75.736474 39.192648, -75.73621300000001 39.192862, -75.736164 39.192961, -75.73621300000001 39.193115, -75.73640399999999 39.193334, -75.736439 39.193433, -75.73645999999999 39.193719, -75.73675 39.19396, -75.737442 39.19468, -75.737605 39.194932, -75.738283 39.195553, -75.738438 39.195794, -75.73846 39.196014, -75.738411 39.196311, -75.738277 39.196563, -75.73820600000001 39.19686, -75.738058 39.197107, -75.738044 39.197179, -75.738073 39.197722, -75.73786800000001 39.198162, -75.737848 39.198832, -75.73777800000001 39.199513, -75.73778 39.199539, -75.737792 39.199672, -75.73780600000001 39.199744, -75.737891 39.199887, -75.738011 39.199985, -75.738534 39.200364, -75.738739 39.200617, -75.738732 39.200793, -75.73871800000001 39.200853, -75.738563 39.20115, -75.73857700000001 39.20132, -75.738612 39.201386, -75.73882399999999 39.201595, -75.738964 39.201805, -75.73890900000001 39.201833, -75.73858 39.202007, -75.738338 39.20214, -75.73824999999999 39.202189, -75.737526 39.202602, -75.736491 39.203202, -75.735878 39.203559, -75.73581799999999 39.203535, -75.73562 39.203491, -75.735507 39.203486, -75.73532400000001 39.203508, -75.73465400000001 39.203719, -75.733997 39.203926, -75.733806 39.203975, -75.73321300000001 39.204063, -75.73314999999999 39.20408, -75.732832 39.204245, -75.732218 39.204399, -75.731013 39.204767, -75.730729 39.204855, -75.730496 39.204839, -75.730178 39.204768, -75.730093 39.204735, -75.729811 39.204586, -75.729784 39.204557, -75.729703 39.204472, -75.729676 39.204444, -75.72949300000001 39.203883, -75.729337 39.202955, -75.72921599999999 39.202543, -75.729258 39.202131, -75.72928 39.20206, -75.729597 39.201521, -75.729682 39.201225, -75.729681 39.201148, -75.729653 39.201011, -75.729437 39.200625, -75.72941299999999 39.200582, -75.729342 39.200511, -75.729095 39.200308, -75.72872099999999 39.200033, -75.72813499999999 39.199654, -75.72636199999999 39.198979, -75.72553600000001 39.198436, -75.72519 39.198073, -75.725049 39.197826, -75.72492800000001 39.197436, -75.72466 39.197057, -75.724377 39.19675, -75.724194 39.196629, -75.72372799999999 39.19647, -75.723586 39.196437, -75.72305 39.196388, -75.722943 39.196335, -75.72287300000001 39.1963))',
 'POLYGON ((-75.70958899999999 39.191293, -75.72287300000001 39.1963, -75.722943 39.196335, -75.72305 39.196388, -75.723586 39.196437, -75.72372799999999 39.19647, -75.724194 39.196629, -75.724377 39.19675, -75.72466 39.197057, -75.72492800000001 39.197436, -75.725049 39.197826, -75.72519 39.198073, -75.72553600000001 39.198436, -75.72636199999999 39.198979, -75.72813499999999 39.199654, -75.72872099999999 39.200033, -75.729095 39.200308, -75.729342 39.200511, -75.72941299999999 39.200582, -75.729437 39.200625, -75.729653 39.201011, -75.729681 39.201148, -75.729682 39.201225, -75.729597 39.201521, -75.72928 39.20206, -75.729258 39.202131, -75.72921599999999 39.202543, -75.729337 39.202955, -75.72949300000001 39.203883, -75.729676 39.204444, -75.729281 39.204142, -75.72863099999999 39.203708, -75.728419 39.20362, -75.728313 39.203615, -75.72762899999999 39.203642, -75.72674600000001 39.203797, -75.726097 39.203978, -75.72579399999999 39.204033, -75.72568 39.204055, -75.724501 39.204341, -75.723358 39.204523, -75.72296900000001 39.204572, -75.722369 39.204605, -75.7216 39.204628, -75.721346 39.204622, -75.720809 39.204518, -75.72007499999999 39.204287, -75.71960199999999 39.204205, -75.71827399999999 39.204162, -75.717872 39.204189, -75.717392 39.204266, -75.71716600000001 39.204299, -75.716933 39.204288, -75.71686200000001 39.204244, -75.716679 39.204091, -75.71629 39.203734, -75.71598 39.203503, -75.716008 39.203305, -75.715951 39.203185, -75.715294 39.202613, -75.71499799999999 39.2023, -75.71492000000001 39.202256, -75.714793 39.202229, -75.714609 39.202174, -75.714372 39.202043, -75.714151 39.201922, -75.714037 39.20174, -75.713854 39.201301, -75.71375500000001 39.201164, -75.71358499999999 39.201059, -75.713268 39.200977, -75.713134 39.2009, -75.712632 39.200576, -75.711347 39.200533, -75.711016 39.200505, -75.71091 39.200489, -75.71085600000001 39.200461, -75.710886 39.20022, -75.71099700000001 39.199436, -75.71102500000001 39.199202, -75.711023 39.198954, -75.711015 39.198794, -75.710992 39.198631, -75.71098600000001 39.198605, -75.71083400000001 39.197926, -75.71016299999999 39.195421, -75.709985 39.194788, -75.70979699999999 39.193841, -75.709699 39.193437, -75.70966799999999 39.193159, -75.709647 39.192967, -75.70962400000001 39.192378, -75.70961 39.191867, -75.709603 39.191594, -75.70958899999999 39.191293))',
 'POLYGON ((-75.73244 39.214083, -75.730515 39.213414, -75.72474 39.211409, -75.722815 39.210741, -75.723426 39.210463, -75.72396999999999 39.210199, -75.724549 39.209892, -75.72523099999999 39.209502, -75.725463 39.209373, -75.726288 39.208918, -75.72690900000001 39.208565, -75.727627 39.208158, -75.72804499999999 39.207926, -75.72817000000001 39.207857, -75.730197 39.20674, -75.733288 39.205037, -75.734129 39.204574, -75.735878 39.203559, -75.73618500000001 39.203678, -75.736602 39.203815, -75.736672 39.203829, -75.736983 39.203891, -75.738134 39.20394, -75.738452 39.203891, -75.738995 39.203748, -75.73916199999999 39.203715, -75.73968000000001 39.203616, -75.73999000000001 39.203571, -75.74020899999999 39.203654, -75.740647 39.203758, -75.740686 39.203778, -75.740922 39.203901, -75.74142399999999 39.204274, -75.74153 39.204323, -75.74263000000001 39.204744, -75.74303399999999 39.204899, -75.743154 39.204932, -75.743326 39.204937, -75.743257 39.205981, -75.743229 39.206427, -75.743171 39.207816, -75.743165 39.207962, -75.743098 39.209117, -75.743039 39.210163, -75.743005 39.210749, -75.74294399999999 39.211073, -75.742897 39.211246, -75.74276 39.211583, -75.74274800000001 39.211615, -75.741614 39.214085, -75.74100900000001 39.215526, -75.740983 39.215586, -75.740844 39.215917, -75.740392 39.216922, -75.738801 39.216354, -75.73403 39.21465, -75.73244 39.214083))',
 'POLYGON ((-75.710657 39.202046, -75.710696 39.201728, -75.71081599999999 39.200777, -75.71085600000001 39.200461, -75.71091 39.200489, -75.711016 39.200505, -75.711347 39.200533, -75.712632 39.200576, -75.713134 39.2009, -75.713268 39.200977, -75.71358499999999 39.201059, -75.71375500000001 39.201164, -75.713854 39.201301, -75.714037 39.20174, -75.714151 39.201922, -75.714372 39.202043, -75.714609 39.202174, -75.714793 39.202229, -75.71492000000001 39.202256, -75.71499799999999 39.2023, -75.715294 39.202613, -75.715951 39.203185, -75.716008 39.203305, -75.71598 39.203503, -75.71629 39.203734, -75.716679 39.204091, -75.71686200000001 39.204244, -75.716933 39.204288, -75.71716600000001 39.204299, -75.717392 39.204266, -75.717872 39.204189, -75.71827399999999 39.204162, -75.71960199999999 39.204205, -75.72007499999999 39.204287, -75.720809 39.204518, -75.721346 39.204622, -75.7216 39.204628, -75.722369 39.204605, -75.72296900000001 39.204572, -75.723358 39.204523, -75.724501 39.204341, -75.72568 39.204055, -75.72579399999999 39.204033, -75.726097 39.203978, -75.72674600000001 39.203797, -75.72762899999999 39.203642, -75.728313 39.203615, -75.728419 39.20362, -75.72863099999999 39.203708, -75.729281 39.204142, -75.729676 39.204444, -75.729703 39.204472, -75.729784 39.204557, -75.729811 39.204586, -75.730093 39.204735, -75.730178 39.204768, -75.730496 39.204839, -75.730729 39.204855, -75.731013 39.204767, -75.732218 39.204399, -75.732832 39.204245, -75.73314999999999 39.20408, -75.73321300000001 39.204063, -75.733806 39.203975, -75.733997 39.203926, -75.73465400000001 39.203719, -75.73532400000001 39.203508, -75.735507 39.203486, -75.73562 39.203491, -75.73581799999999 39.203535, -75.735878 39.203559, -75.734129 39.204574, -75.733288 39.205037, -75.730197 39.20674, -75.72817000000001 39.207857, -75.72804499999999 39.207926, -75.727627 39.208158, -75.72690900000001 39.208565, -75.726288 39.208918, -75.725463 39.209373, -75.72523099999999 39.209502, -75.724549 39.209892, -75.72396999999999 39.210199, -75.723426 39.210463, -75.722815 39.210741, -75.72192099999999 39.210458, -75.721829 39.210429, -75.71924199999999 39.20961, -75.718349 39.209328, -75.71829200000001 39.209244, -75.718124 39.208992, -75.718068 39.208909, -75.71773399999999 39.208412, -75.717641 39.208262, -75.717511 39.20808, -75.71740800000001 39.207966, -75.71730100000001 39.207886, -75.717259 39.207854, -75.717207 39.207851, -75.71713200000001 39.207813, -75.717033 39.207783, -75.716909 39.207728, -75.71651799999999 39.207609, -75.71639399999999 39.207578, -75.715901 39.207458, -75.714135 39.206993, -75.71284 39.206636, -75.712093 39.206369, -75.711579 39.206173, -75.71121599999999 39.206013, -75.710753 39.205777, -75.710537 39.205593, -75.71043 39.205477, -75.710363 39.205363, -75.710303 39.205189, -75.710297 39.205134, -75.710296 39.205116, -75.710339 39.20475, -75.710379 39.20425, -75.71048 39.203413, -75.710556 39.202901, -75.710576 39.202729, -75.71063599999999 39.202217, -75.710657 39.202046))',
 'POLYGON ((-75.738964 39.201805, -75.73919100000001 39.202149, -75.73932600000001 39.202352, -75.739538 39.202665, -75.739754 39.203242, -75.739785 39.203324, -75.73984900000001 39.203445, -75.73999000000001 39.203571, -75.73968000000001 39.203616, -75.73916199999999 39.203715, -75.738995 39.203748, -75.738452 39.203891, -75.738134 39.20394, -75.736983 39.203891, -75.736672 39.203829, -75.736602 39.203815, -75.73618500000001 39.203678, -75.735878 39.203559, -75.736491 39.203202, -75.737526 39.202602, -75.73824999999999 39.202189, -75.738338 39.20214, -75.73858 39.202007, -75.73890900000001 39.201833, -75.738964 39.201805))']

Should this be relevant, I have attempted this on both GeoPandas 0.2.1 and 0.3.0.

1 Answer 1

1

I should not have been comparing with another GeoSeries but instead with a single Shapely object. One way to accomplish what I desired is through the following method:

from shapely.geometry import MultiPoint

single_shapely_compare = MultiPoint(poi_fresh.geometry)
ax = subset_fresh[subset_fresh.intersects(single_shapely_compare)].plot(color='b')
poi_fresh.plot(ax=ax, color='r')

This would have generated the following plot, which is the desired/expected result: enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.