TransWikia.com

SQL BigQuery ST_CONTAINS geography and Python visualization mismatch

Geographic Information Systems Asked by Kuki on October 7, 2020

I am interested in whether the GPS points (PointWKT) coming from the vehicle were inside or outside of fields/polygons (BoundaryWKT). This was my SQL code to test it:

Select SerialNumber, DateTime, BoundaryWKT, PointWKT,
ST_CONTAINS(tractors_polygons.BoundaryWKT, tractors_polygons.PointWKT) as onField, 
from tractors_polygons
order by DateTime

After running the code, i got another column called onField (BOOL), which would told me whether the GPS point was inside or outside of the polygon. Afterwards i imported my data from BQ to Python, visualize all the polygons and then apply a layer of GPS points filtering out whether the values in column onField were True or False.

This is what i got (I circled one specific field with blue pen for easier orientation and understanding of my problem) :

1. BASE as you can see, there are clearly visible boundaries of all polygons.

base = geo_bound[geo_bound['SerialNumber'] == 'A0000000'].plot(color='white', edgecolor='black', figsize=(100, 100))

enter image description here

2. onField == True From the image below, the logic would be, that tractor was not driving over the entire field but only over the part of it.

base = geo_bound[geo_bound['SerialNumber'] == 'A0000000'].plot(color='white', edgecolor='black', figsize=(100, 100))

geo_trac[((geo_trac['onField'] == True)) & ((geo_trac['SerialNumber'] == 'A0000000'))].plot(ax=base, marker='o', color='red', markersize=1);

enter image description here

3. onField == False here i would expect red dots only in lines outside the boundaries as an indication of tractor driving on the road, but as you can see, a part of circled blue area is also covered in red.

Did anyone have the same problem with BQ function ST_CONTAINS? Is there an explanation why such a thing would happened? I would appreciate your help or any kind of suggestion. Thanks.

enter image description here

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP