25 Apr 2015

Offline Map Tiles with Mapbox-Studio and MOBAC

I just found I neat workaround on how to get your Mapbox projects (Mapbox is a free, fully customizeable Tool for map design) to any local tile storage format that it also available in MOBAC (MOBAC is a free software for the creation of local map tiles from variable sources, in a bunch of different formats, to be used on almost any mobile device)!

  • Get Mapbox-Studio and design your custom map
  • Upload your project to mapbox
  • Create an account and connect to it
  • Get your username, project ID and an access token, which are put to the URL for fetching the tiles back from the Mapbox server: http://api.tiles.mapbox.com/v4/your_username.your_project_id/{$z}/{$x}/{$y}.png?access_token=your_private_or_public_api_key

  • Use the following XML (replacing user, project ID and access token) for a custom mapsource in MOBAC.

    
    
     MAPBOX
     0
     18
     png
     None
     http://api.tiles.mapbox.com/v4/gimoya.ganok9hk/{$z}/{$x}/{$y}.png?access_token=pk.eyJ1IjoiZ2ltb3lhIiwiYSI6IkZrTld6NmcifQ.eY6Ymt2kVLvPQ6A2Dt9zAQ 
     #000000
    
    
  • 10 Apr 2015

    Custom Google Hybrid Mapsource for MOBAC and GALILEO

    For anyone having trouble with the shipped Google Hybrid mapsource, as I encountered them - here is a custom mapsource which worked for me. Save this as XML (under Win7) to ..

    
    
       Custom Google Hybrid
       10
       19
       png
       None
            http://mt{$serverpart}.google.com/vt/lyrs=y&x={$x}&y={$y}&z={$z}
      0 1 
       #000000
    
    

    And for any Galileo user interested, I also add a custom mapsource:

    
     
    Google Hybrid 
    http://mt{$serverpart}.google.com/vt/lyrs=y&x={$x}&y={$y}&z={$z}
    0 1 
    
    

    8 Apr 2015

    QspatiaLite Use Case: Find Number of Species from Point Data

    Here's a short follow up on some previous posting about the use of QspatiaLite for the aggregation of species distribution data. In this case the species data comes as a point layer. For each cell of a 1000 x 1000 m grid (1) the number of individuals per species, (2) the total number of individuals and (3) the number of different species should be calculated.


    There is a layer with 10 different species (variabel name is "sp") across the whole extent with names "1", "2", "3", .. , "10" and a layer with the grid cells (variable name = "id") numbered consecutively, from 1 to 150.

    In the attribute table of the below screenshot you see that I selected the grid cell with id=1 and the points (=species) within this cell. There are 8 individuals - "4", "5", "6" and "10" occure once, whereas "2" and "8" occure twice.

    The query table in the screenshot is the result for (3).


    For (1) you have to query for points/species within grid cells and group over grid cells and species and take the count from that aggregation
    SELECT
     t.gID AS gID,
     t.sp AS Sp,
     count(*) AS NrIndSp
    FROM (SELECT
      g.id AS gID, 
      s.sp AS sp
    FROM grid AS g JOIN Sp_distr AS s 
    ON within(s.Geometry, g.Geometry)
    ) as t GROUP BY t.gId, t.sp
    

    For (2) you simple need to query for points/species within grid cells and aggregate over grid cells:

    Select 
     t.gID,
     count(*) as NrInd
    From (SELECT
      g.id AS gID, 
      s.sp AS sp
    FROM grid AS g JOIN Sp_distr AS s 
    ON within(s.Geometry, g.Geometry)
    ) as t 
    GROUP BY t.gID 
    ORDER BY t.gID
    

    For (3) you'll first need to aggregate over grid cells and points/species, and then again aggregate over this query table by grid cells which will finally give you the distinct species!

    SELECT 
     v.gID,
     count(*) AS SpNr
    FROM (SELECT 
     t.gID,
     t.sp
    FROM (SELECT
      g.id AS gID, 
      s.sp AS sp
    FROM grid AS g JOIN Sp_distr AS s 
    ON within(s.Geometry, g.Geometry)
    ) as t GROUP BY t.gId, t.sp
    ) as v GROUP BY v.gId