0

I have a set of points for a number of buildings in NYC. I would like to group those points into clusters per their respective neighborhood (ex: Chelsea, Upper East Side etc.). Each of my points have a designated neighborhood.

Is there a way to tweak the CSS to make it happen? I don't quite understand how the Wizard is currently clustering my points:

    /** cluster visualization */

#data{
  marker-width: 12;
  marker-fill: #FD8D3C;
  marker-line-width: 1.5;
  marker-fill-opacity: 1;
  marker-line-opacity: 1;
  marker-line-color: #fff;
  marker-allow-overlap: true;

  [src = 'bucketE'] {
    marker-line-width: 5;
    marker-width: 24;
  } 

  [src = 'bucketD'] {
    marker-line-width: 5;
    marker-width: 34;
  } 

  [src = 'bucketC'] {
    marker-line-width: 5;
    marker-width: 44;
  } 

  [src = 'bucketB'] {
    marker-line-width: 5;
    marker-width: 54;
  } 

  [src = 'bucketA'] {
    marker-line-width: 5;
    marker-width: 64;
  } 
}

#data::labels { 
  text-size: 0; 
  text-fill: #fff; 
  text-opacity: 0.8;
  text-name: [points_count]; 
  text-face-name: 'DejaVu Sans Book'; 
  text-halo-fill: #FFF; 
  text-halo-radius: 0; 

  [src = 'bucketE'] {
    text-size: 12;
    text-halo-radius: 0.5;
  }

  [src = 'bucketD'] {
    text-size: 17;
    text-halo-radius: 0.5;
  }

  [src = 'bucketC'] {
    text-size: 22;
    text-halo-radius: 0.5;
  }

  [src = 'bucketB'] {
    text-size: 27;
    text-halo-radius: 0.5;
  }

  [src = 'bucketA'] {
    text-size: 32;
    text-halo-radius: 0.5;
  }

  text-allow-overlap: true;

  [zoom>4]{ text-size: 16; }
  [points_count = 1]{ text-size: 0; }
}

1 Answer 1

1

I'm not sure if you can do it with pure styling, but by manipulating your tables some you can likely get your desired result.

I would find a shapefile of NYC neighborhoods and upload that to Cartodb, then merge tables with a spatial join. Likely just doing count, to get the number of features, though you could also sum on a property.

That will give you a table of the neighborhoods, with the number of your features as a column. Personally I'd just display the polygons with a label of the count of the features. But if you really wanted it as a circle you could take the centroid of the neighborhood, populating it with ST_Centroid(the_geom) from your table (easiest would probably be to create a new table). Then you can style that as you like.

1
  • Thanks, that's a great workaround! I'll put your advice into practice and get back to you later.
    – Hadrien
    Commented Mar 27, 2015 at 2:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.