GeoSeries.touches(other) and GeoSeries.intersects(other) unexpected behavior
See original GitHub issueSo 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:
- Created 5 years ago
- Comments:9 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:
– Michelle Ho Data Scientist mho@carto.com
Closing this in favor of the geopandas one