AtlasOfLivingAustralia / spatial-hub

New spatial portal front end using AngularJS
https://spatial.ala.org.au/
7 stars 16 forks source link

Double gridding Tool - Occupancy Grids #49

Closed Tasilee closed 1 year ago

Tasilee commented 7 years ago

Donald Hobern demonstrated some GBIF scripts that may prove handy for comparing aggregated data across the three dimensions of name, space and time. Certainly relevant to EBVs and SoE. It goes like this

  1. Supply a taxa (usually a genus or higher)

  2. Supply a primary grid size (e.g., 0.1 degree or 10km)

  3. Supply s secondary grid size (e.g., 1 degree or 100km)

  4. Supply a temporal bin range (e.g., 10 years)

  5. Generate a points to grid using the primary grid size on the taxa

  6. Calculate the new layers at the secondary grid size for each time slice a. Number of non-null primary grid cells (bins) b. Number of species in bins c. Number of occurrences in bins d. For each species present: Number of occurrences for species x in bins

An example of the type of data produced-

latitudeRange longitudeRange timePeriod speciescount bincount occurrenceount Streptopelia roseogrisea (Sundevall, 1857) Streptopelia mayeri (Prevost, 1843) ...
-74.0,-73.0 +030.0,+031.0 2000-2017 1 1 2    
-44.0,-43.0 +146.0,+147.0 2000-2017 1 1 1    
-44.0,-43.0 +147.0,+148.0 2000-2017 1 5 5    
-44.0,-43.0 +172.0,+173.0 2000-2017 1 29 31 29  
-43.0,-42.0 +147.0,+148.0 1900-1969 1 3 3    
-43.0,-42.0 +147.0,+148.0 1970-1999 1 9 9    
-43.0,-42.0 +147.0,+148.0 2000-2017 1 545 606    

The double gridding removes much of the point-sampling bias and aggregates the data to a level where comparisons across name, space and time should be useful.

adam-collins commented 4 years ago

https://github.com/AtlasOfLivingAustralia/spatial-service/blob/develop/src/main/groovy/au/org/ala/spatial/process/DoubleGridding.groovy

qifeng-bai commented 3 years ago

@adam-collins GET http://devt.ala.org.au:8087/spApp/DoubleGriddingContent.htm 404 DoubleGriddingContent.htm is not committed into git yet

qifeng-bai commented 3 years ago

@adam-collins By choosing "Streptopelia", and "Australia" area, Double grids tool works However, if we select area "World", it produces empty records

Found one possible reason: https://github.com/AtlasOfLivingAustralia/spatial-service/blob/master/src/main/groovy/au/org/ala/spatial/analysis/layers/DoubleGriddingGenerator.java#L156

When we select "world" as area, bbox of regions is -180, -90 -- 180, 90 region.isWithin_EPSG900913(112.45, -43 ) return false

Screen Shot 2021-01-08 at 12 18 53 pm

However, if we choose Australia area -- bbox 112,-4 : 115,-9, it returns true

Screen Shot 2021-01-08 at 12 26 54 pm
qifeng-bai commented 3 years ago

I have added a test for this case: https://github.com/AtlasOfLivingAustralia/spatial-service/blob/49_double_grid/src/test/groovy/au/org/ala/spatial/util/SimpleRegionSpec.groovy

Set bbox latitude to 90/-90 will fail the test

if we define a region: SimpleShapeFile.parseWKT("POLYGON((-180 -89,180 -89,180 89,-180 89,-180 -89))"); succeed on checking : assertTrue(region.isWithin_EPSG900913(112.45, -43))

but a region defined asSimpleShapeFile.parseWKT("POLYGON((-180 -90,180 -90,180 90,-180 90,-180 -90))"), assertTrue(region.isWithin_EPSG900913(112.45, -43)) will fail

Dig deeper, we can see:

SpatialUtil.convertLatToPixel( -90) = -1 SpatialUtil.convertLatToPixel( -89) = 673563127

Deeper: in method: convertLatToPixel(double lat) Math.log((1.0D + Math.sin(lat 3.141592653589793D / 180.0D)) / (1.0D - Math.sin(lat 3.141592653589793D / 180.0D)))

When lat = -90 or 90, Math.log returns infinity

qifeng-bai commented 3 years ago

@adam-collins points out we need to use 179.9999 89.9999 We modified the boundary of world in application.yml of Spatial Hub

Tasilee commented 3 years ago

With this type of tool, we probably need to limit the area to far less than global, given our mandate. Running it on Australia (~8 million sq.km) would make sense and Southern Ocean (similar size) likewise. We leave the larger areas to GBIF.

qifeng-bai commented 3 years ago

@Tasilee I created a new ticket for this improvement. https://github.com/AtlasOfLivingAustralia/spatial-hub/issues/367