Mapping an Integer

So just before Christmas I received my own “hand-crafted”, “unique”, and “hella-beautiful” integer. From Brooklyn Integers: 404578811.

http://www.brooklynintegers.com/int/404578811/

I was not initially sure what to do with it. But I had some time while waiting on points to appear in polygons so I though I would map my integer.

So we have a few combinations for co-ordinates:

  • 0, 404578811
  • 4 , 04578811
  • 40 , 4578811
  • 404 , 578811
  • 4045 , 78811
  • 40457 , 8811
  • 404578 , 811
  • 4045788 , 11
  • 40457881 , 1
  • 404578811, 0
  • And of course:

  • 404578811, 404578811
  • I have to say these do not translate very well into my current de facto co-ordinate system of British National Grid (0, 404578811 and 404578811, 0 and 404578811, 404578811 not shown).

    BNG_no_good

    Luckily we can try some alternatives. Smathermather had a great post about mapping Null Island/Archipelago, so we can re-use some code. To map our integers to a selection of CRSs.

    CREATE OR REPLACE FUNCTION integer_mapping2(
    
        crs integer,
    
        x integer,
    
        y integer)
    
      RETURNS geometry AS
    
    $BODY$
    
    DECLARE
    
        BODY geometry;
    
    BEGIN
    
    SELECT ST_Transform(ST_SetSRID(ST_MakePoint(x,y),crs), 4326) INTO BODY;
    
    RETURN BODY;
    
    EXCEPTION
    
        WHEN SQLSTATE 'XX000' THEN
    
        RETURN NULL;
    
    END
    
    $BODY$
    
      LANGUAGE plpgsql;

    We use the EXCEPTION, because some of the more awkward co-ordinate combinations cannot be translated back to EPSG:4326 without causeing a SQL error.

    Then we can create our our tables.

    CREATE TABLE my_integer_ AS
    
    SELECT srid, integer_mapping2(srid, 404578811,404578811) as geom FROM spatial_ref_sys
    
        WHERE srid > 2000 AND srid < 4904;

    Replacing 404578811_404578811 as needed.

    Mapped:

    by_co_ord

    By CRS:

    by_crs

    4,04578811:

    4_04578811

    Album of the rest.

    It really shows how fragmented the EPSG codes are for New Zealand, and to a lesser extent the US.

    Every Person in Scotland on the Map

    Winner of the 2016 OS OpenData Award for Excellence in the use of OpenData from the British Cartographic Society.

    Full size.

    The mapping process creates a random point within a building shell inside of a postcode area, which is repeated for every person in a postcode. This is in contrast to a simpler process, which does not take into account buildings at all, working simply with postcode areas. This can be seen in my previous post: Population of Scotland Mapped

    Inspired by:
    The Guardian – Every person in England and Wales on a map by Chris Cross

    Based on the 2011 Scottish Census population data.

    Data from the National Records of Scotland.

    Combined with the Ordnance Survey, Open Map product.

    Rendered with: QGIS tile writer python script.