3

I am dealing with some sensitive data for which providing a high resolution of accuracy of the location would be detrimental. However, the general location is not sensitive and useful to share.

I would like to use Carto CSS to generalize the point visualization above a certain zoom level. The goal would be to style the points as a non scaling marker of a fixed large width .. or a question mark icon or something similar. I know naturalists does this with certain sensitive biodiversity data.

Any advice or examples?

1 Answer 1

1

Solution 1. Enter the following in the CartoDB editor's "CSS" tab

#your_data_layer{
  marker-line-width: 0;
  marker-line-opacity: 0;
  marker-fill-opacity: 1;
  marker-fill: #FF6600;
  marker-type: ellipse;
  marker-width: 8;
  marker-allow-overlap: true;
  [zoom > 10] {
      [zoom = 11] { marker-width: 16;}
      [zoom = 12] { marker-width: 32;}
      [zoom = 13] { marker-width: 64;}
      [zoom = 14] { marker-width: 128;}
      [zoom = 15] { marker-width: 256;}
      [zoom = 16] { marker-width: 512;}
      [zoom = 17] { marker-width: 1024;}
      [zoom >= 18] { marker-width: 2048;}
  }
}

This makes the marker for the data the same size (in map units) when the user is zoomed in past the 10 level. Every zoom level is a doubling of the map scale (i.e. the same distance on the ground takes up twice as much distance on the screen as the preceding lower zoom level), therefore you have to double the size of the markers (which are specified in pixels) with every higher zoom level in order that the marker remain the same size in map units.

Solution 2, enter this in the CartoDB editor's "CSS" tab:

#your_data_layer{
  marker-line-width: 0;
  marker-line-opacity: 0;
  marker-fill-opacity: 1;
  marker-fill: #FF6600;
  marker-type: ellipse;
  marker-width: 8;
  marker-allow-overlap: true;
  [zoom > 10] {
    marker-fill-opacity: 0;
  }
}

This simply does not render the data (because we have set the opacity to zero) when the user is zoomed in too close (> zoom level 10 in this example).

3
  • 1
    This is a great workaround .. and exactly what I was thinking. However, I was discussing this idea with some other GIS scientists and they pointed out that someone using "inspect element" or other inspection tool could still see the coordinates if they wanted. They suggested a more complex process of randomizing the data or snapping to a predetermined grid for more data provacy.. just food for thought!
    – Adam C
    Commented Jan 14, 2016 at 17:36
  • @Adam C - You tagged your question with "cartodb", is that the platform you are using? I am unaware of any "inspect element" functionality in CartoDB that is enabled by default. In so far as inspecting traffic (e.g. with Wireshark), all of the rendering takes place on the server so there are no coordinates to see. Of course you could add a little noise to your data beforehand, but you asked about solving the issue in Carto CSS. If I am missing some way of "seeing" the coordinates, I would like to know about it.
    – tekim
    Commented Jan 15, 2016 at 22:43
  • I am referring to Inspect element via the Chrome Browser. With enough digging (and knowledge) you can identify the geometry.
    – Adam C
    Commented Mar 2, 2016 at 1:35

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.