question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GeoSeries.touches(other) and GeoSeries.intersects(other) unexpected behavior

See original GitHub issue

So using these two datasets, we ran into some unexpected behavior of the intersect and touches functions.

assigned_bins = cc.read('assigned_hexbins')
unassigned_bins = cc.read('unassigned_hexbins')

assigned_hexbins.csv.zip unassigned_hexbins.csv.zip

We converted the dataframes into geodataframes

unassigned_bins =cc.query('SELECT *, ST_AsText(the_geom) as geom FROM mspichigercarto.unassigned_hexbins').reset_index()
assigned_bins =cc.query('SELECT *, ST_AsText(the_geom) as geom FROM mspichigercarto.assigned_hexbins').reset_index()

import shapely.wkt

geometry = unassigned_bins['geom'].map(shapely.wkt.loads)
unassigned_bins = unassigned_bins.drop('geom', axis=1)
crs = {'init': 'epsg:4326'}
unassigned_bins_geo = gpd.GeoDataFrame(unassigned_bins, crs=crs, geometry=geometry)`
import shapely.wkt

geometry = assigned_bins['geom'].map(shapely.wkt.loads)
assigned_bins = assigned_bins.drop('geom', axis=1)
crs = {'init': 'epsg:4326'}
assigned_bins_geo = gpd.GeoDataFrame(assigned_bins, crs=crs, geometry=geometry)

Then we tried running touches and intersects on them, but instead of returning expected values it would return false for everything and none of the geometries intersected.

assigned_bins_geo.touches(unassigned_bins_geo)

We then ran this query in cartoframes

st_touch_query = '''
SELECT assigned_hexbins.*,
      unassigned_hexbins.cartodb_id as index_unassigned
FROM assigned_hexbins, unassigned_hexbins
WHERE ST_Touches(assigned_hexbins.the_geom, unassigned_hexbins.the_geom)
'''

according to this query, the hexbins are touching so touches and intersects are not working as expected.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
michellemhocommented, Jun 19, 2018

Yes, it doesn’t seem to be related to cartoframes. It has to do with Geopandas intersection methods.

On Tue, Jun 19, 2018 at 9:58 AM Andy Eschbacher notifications@github.com wrote:

Hey all, how’s this going? Overall it looks like it doesn’t have to do with cartoframes

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/CartoDB/cartoframes/issues/449#issuecomment-398408594, or mute the thread https://github.com/notifications/unsubscribe-auth/AL-ECYlWt9REZNTieNA-Du3YqaFA4stkks5t-QOTgaJpZM4UjUwr .

Michelle Ho Data Scientist mho@carto.com

0reactions
andy-eschcommented, Jun 19, 2018

Closing this in favor of the geopandas one

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Unexpected intersects behavior between GeoSeries ...
I should not have been comparing with another GeoSeries but instead with a single Shapely object. One way to accomplish what I desired...
Read more >
geopandas.GeoSeries.touches
An object is said to touch other if it has at least one point in common with other and its interior does not...
Read more >
Geopandas touches method on geoseries does not work as I ...
Yes, this is the expected (but sometimes surprising) behaviour: if you pass another GeoSeries as argument, the 'touches' operation is done ...
Read more >
GeoPandas Documentation - Read the Docs
interior of the other object and their boundaries do not touch at all. GeoSeries.crosses(other). Returns a Series of dtype('bool') with ...
Read more >
Mapping Toolbox User's Guide - Index of /
by the federal government (or other entity acquiring for or through the federal ... mapexgeo — Creating Maps using geoshow (for latitude, longitude...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found