How can I get the NYC taxi zone using a given coordinate?

503 views Asked by At

NYC Taxi trips dataset in BigQuery has changed pickup and dropoff locations from the geographic positions(longitude and latitude) to the Taxi zone. I found NYC Taxi Zones but I'm struggling to get the zone from the given coordinates.

I think it is related to multipolygon but not sure. Does anyone can help me to provide a simple example to get the zone from a coordinate?

1

There are 1 answers

1
Hyunuk On

Found this link to figure out how.

/* find the boroughs and zone names for dropoff locations */
INNER JOIN `bigquery-public-data.new_york_taxi_trips.taxi_zone_geom` tz_do ON 
(ST_DWithin(tz_do.zone_geom,ST_GeogPoint(dropoff_longitude, dropoff_latitude), 0))
/* find the boroughs and zone names for pickup locations */
INNER JOIN `bigquery-public-data.new_york_taxi_trips.taxi_zone_geom` tz_pu ON 
(ST_DWithin(tz_pu.zone_geom,ST_GeogPoint(pickup_longitude, pickup_latitude), 0))