top of page
Search

Which restaurants are in the taxi districts of New York City?

  • danielwu779
  • Oct 19, 2024
  • 1 min read

So, this is kind of like a follow up to the last post. But I decided to look at how the taxi districts stack up in terms of restaurants.


First, I downloaded data from the DOHMH-New-York-City-Restaurant-Inspection-Results. This is a list of every single restaurant inspection in NYC, so this is solid. Next, I cleaned the data. Every restaurant is (fortunately) inspected more than once, so I used the following code in python:

import pandas as pd
df = pd.read_csv('Restaurants.csv')
df.head()
df_cleaned = df.drop_duplicates(subset='CAMIS', keep=False)
df_cleaned.head()

Next with this exported CSV, I converted it to a Shapefile – to put into our good old friend the Google earth engine.


Using this code:

// Load your restaurant data (restaurants10k)
var restaurants = ee.FeatureCollection("users/danielwu779/restaurants10k");
// Load the taxi zones (assuming they are already added to GEE)
var taxiZones = ee.FeatureCollection("users/danielwu779/yourTaxiZoneAsset");
// Spatial join: counting the number of restaurants in each taxi zone
var joined = taxiZones.map(function(zone) {
  // Count the number of restaurants within each taxi zone
  var restaurantCount = restaurants.filterBounds(zone.geometry()).size();
  
  // Add the count as a property to the taxi zone
  return zone.set('restaurant_count', restaurantCount);
});
// Print the result to check the taxi zones with restaurant counts
print('Taxi Zones with Restaurant Counts', joined);

This gives you the amount of restaurants for each taxi zone. Happy analysis!

 
 
 

Recent Posts

See All
Gastrodiplomacy

Introduction to Gastrodiplomacy In an increasingly interconnected world, gastrodiplomacy has emerged as a unique and effective tool for...

 
 
 

Comments


Subscribe here to get my latest posts

Thanks for submitting!

© 2035 by The Book Lover. Powered and secured by Wix

  • Facebook
  • Twitter
bottom of page