Data of New York

Here’s the latest addition to my Creative Bots project. Data of New York is a pair of Twitter and Mastodon bots that let you explore the city of New York with maps made with Mapbox and NYC Open Data.

The bot looks through datasets on NYC OpenData using the Socrata Discovery API.

const dataSource = 'data.cityofnewyork.us';
const dataType = helpers.randomFromArray( [
  'datasets',
  'map'
] );

const dataLimit = '1000';
const discoveryUrl = `http://api.us.socrata.com/api/catalog/v1?domains=${ dataSource }&search_context=${ dataSource }&only=${ dataType }&limit=${ dataLimit }`;

console.log( `finding a dataset in the ${ dataSource } domain (${ dataType })` );

Originally I wanted to create charts using the data, sort of an automated version of @last100bills, but this is a bit tricky to get right, as most datasets have too many columns, and the charts would be pretty unreadable. I’m still going to keep looking into this, but for now the bot looks for datasets that contain location information, such as latitude and longitude, or a zip code, and uses it to generate maps.

With Google starting to charge for their Static Maps service, I’ve decided to go with Mapbox for this project.

data.forEach( function( datapoint ){
  if ( datapoint.longitude && datapoint.latitude ){
    markers.push( `pin-s+555555(${ datapoint.longitude },${ datapoint.latitude })` )
  } else if ( datapoint.lon && datapoint.lat ){
    markers.push( `pin-s+555555(${ datapoint.lon },${ datapoint.lat })` )
  } else if ( datapoint.location && datapoint.location.longitude && datapoint.location.latitude ){
    markers.push( `pin-s+555555(${ datapoint.location.longitude },${ datapoint.location.latitude })` )
  }
} );

const mapUrl = `https://api.mapbox.com/styles/v1/mapbox/light-v10/static/${ markers.join( ',' ) }/auto/900x600?access_token=${ process.env.MAPBOX_ACCESS_TOKEN }`;

Because of limitations of Mapbox, I am using a randomly selected subset of 100 datapoints, otherwise the map URL becomes too long.

data = helpers.randomFromArrayUnique( data, 100 );

It’s pretty straightforward to create your own version of the bot for your city, as long as it’s part of the OpenData network.

const dataSource = 'data.cityofnewyork.us';
const dataType = helpers.randomFromArray( [
  'datasets',
  'map'
] );

const dataLimit = '1000';
const discoveryUrl = `http://api.us.socrata.com/api/catalog/v1?domains=${ dataSource }&search_context=${ dataSource }&only=${ dataType }&limit=${ dataLimit }`;

You can follow the bot on Twitter and botsin.space.

A tinted screenshot of the Fediverse Export Analyzer interface, showing a visualization of Mastodon user account with profile image and description in the left column, and various details, including account creation date, embedded first post, and posting frequency, and a scatter plot of all posts.

Alt Text Hall of Fame

Making the web a friendlier and more inclusive place, one captioned image at a time.

#accessibility #alt-text #image-descriptions #internet #web #web-accessibility

A tinted screenshot of three embedded Mastodon posts.

💻 Browse all