In Karttur’s GeoImagine Framework all spatial data processing requires a pre-defined region. When you setup the Framework database the top region globe was added to the system. All other regions are hierarchically defined starting from globe. In this post you will add pre-defined regions and create the links between regions and the two tiling systems used with the framework: modis and mgrs.
Prerequisites
You must have the complete SPIDE installed as described in the blog Install and setup spatial data IDE. You must also have setup Karttur’s GeoImagine Framework, either by importing or by copying (drag and drop). You must also have setup the complete Framework database as described in of the previous posts.
How to run processes, including the setup described in this post, is covered in an earlier post. The xml files required for running the processes described in the post are included in the setup_processes package. To understand the structure of the xml file you can read this post.
If your PyDev project does not compile and stop because imports are not found, check which package that is lacking and use the post on Additional packages for support on adding the missing package to you PyDev project.
Python module
The setup of regions is done from the python module setup_process_regions.py. In the main section you can define which parts to install. If you want to change the region categories or default regions that are installed you need to edit the linked xml files.
if __name__ == "__main__":
'''
'''
DefaultRegions = True
MODIS = False
Landsat = False
Sentinel = False
Ancillary = False
Climate = False
verbose = True
'''Link to project file that sets up default regions, arbitrary regions and special regions.
'''
if DefaultRegions:
projFN = 'regions_karttur_setup_20181116.txt'
Setup('regiondoc',projFN,verbose)
if MODIS:
'''Stand alone script that defines the MODIS tile coordinates'''
FPN = ModisTileCoords()
'''
exitstr = 'The script ModisTileCoords() produced a shape with all MODIS SIN tiles projected to Geographic coordiantes.\n \
Copy the shape data sourse: %(fpn)s,\n and edit the xml file for importing this layer.\n \
Then comment out the "exit" command and re-run the module.' %{'fpn':FPN}
exit(exitstr)
'''
projFN = 'modis_karttur_setup_20181116.txt'
Setup('modisdoc',projFN,verbose)
if Sentinel:
'''Link to project file that sets up the Sentinel tiling system'''
projFN = 'sentinel_karttur_setup_2018116.txt'
Setup('sentineldoc',projFN,verbose)
if Landsat:
pass
if MODIS and Sentinel:
'''Stand alone script that links sentinel and modis, requires that all sentinel tiles are in the db'''
LinkSentineModisTiles()
if MODIS and Landsat:
LinkLandsatModisTiles()
if Sentinel and Landsat:
LinkSentinelLandsatTiles()
if Ancillary:
''' link to project file that imports default ancillary data'''
projFN = 'ancillary_karttur_setup_20180221_0.txt'
Setup('ancildoc',projFN,verbose)
if Climate:
''' Climate data'''
projFN = 'climate_karttur_setup_20181116.txt'
Setup('climatedoc',projFN,verbose)
Region categories
As mentioned in the Introduction, the top region is predefined as the entire globe. In the Framework the globe region belongs to the stratum 0. stratum 0 only contains this single region. To accommodate all other potential regions, the following hierarchical region categories are defined:
Stratum
Name
Parent
0
globe
self
1
global
globe
2
pancontinent
global
2
panoceanic
global
3
continent
pancontinent
3
marinecontinent
global
3
oceanic
panoceanic
4
subcontinent
continent
4
marinesubcontinent
marinecontinent
4
suboceanic
oceanic
5
basin
pancontinent
6
subbasin
basin
5
sovereign
global
6
country
sovereign
6
marinecountry
global
6
continentcountry
subcontinent
6
marinecontinentcountry
marinesubcontinent
7
state
country
8
province
state
9
district
province
10
community
district
11
quarter
community
12
domain
any
12
tract
any
13
site
tract
While all processing is related to pre-defined regions at stratum 1 to 11, all user projects must be associated with a tract (stratum 12) that can be divided into sites (stratum 13). All tracts are associated with one (1), and only one, default region (at stratum 1 to 11).
Region categories are added to the Framework through the process regioncategories. The xml file below adds all the categories listed above, and also outlines the differences between different categories.
<?xml version='1.0' encoding='utf-8'?>
<manageregion>
<userproj userid = 'karttur' projectid = 'karttur' tractid= 'karttur' siteid = '*' plotid = '*' system = 'system'></userproj>
<!-- Stratum 0 must be added prior to ading other region categroies-->
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'global' stratum = '1' parentcat = 'globe'
title = 'Global regions, apart from the earth itself'
label = 'Global regions include regions that cover more than one continent, usually girdling the Earth.'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'pancontinent' stratum = '2' parentcat = 'global'
title = 'Continental landmasses'
label = 'Pancontinental include Americas, Eurasia, Africa, Australia, Oceania and Antarctica.'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'panoceanic' stratum = '2' parentcat = 'global'
title = 'Panoceanic regions, covering more than one ocean'
label = 'Panoceanic regions include the Arctic, North Atlantic, Indian, Pacific and Antarctic oceans.'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'continent' stratum = '3' parentcat = 'pancontinent'
title = 'The classical 7 continents'
label = 'Continental include North America, South America, Europe, Asia, Africa, Oceania and Antarctica'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'marinecontinent' stratum = '3' parentcat = 'global'
title = 'The classical 7 continents, including marine regions'
label = 'Marine Continental include North America, South America, Europe, Asia, Africa, Oceania and Antarctica'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'oceanic' stratum = '3' parentcat = 'panoceanic'
title = 'Oceanic regions, covering more than one ocean'
label = 'Oceanic regions include the Arctic, North Atlantic, South Atlantic, Indian, North Pacific, South Pacific and Antarctic oceans .'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'subcontinent' stratum = '4' parentcat = 'continent'
title = 'Regions with subcontinental coverage, covering more than one country'
label = 'Subcontinental regions cover arbitrary regions, defined by e.g. political, climatic or topographic conditions'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'marinesubcontinent' stratum = '4' parentcat = 'marinecontinent'
title = 'Regions with subcontinental coverage, covering more than one country'
label = 'Subcontinental regions cover arbitrary regions, defined by e.g. political, climatic or topographic conditions'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'suboceanic' stratum = '4' parentcat = 'oceanic'
title = 'Regions with suboceanic coverage, including enclosed seas'
label = 'Suboceanic regions cover both defined enclosed seas as well as other oceanic regions falling within a single of the seven classical oceans'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'basin' stratum = '5' parentcat = 'pancontinent'
title = 'Regions with hydrological basin coverage'
label = 'The basin region category contains the worlds hydrological basins (watersheds)'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'subbasin' stratum = '6' parentcat = 'basin'
title = 'Regions with hydrological subasin coverage'
label = 'The subbasin region category contains subbasins of basins (watersheds)'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'sovereign' stratum = '5' parentcat = 'global'
title = 'Sovereign (composite) nation states'
label = 'Sovereign (composite) nation states'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'country' stratum = '6' parentcat = 'sovereign'
title = 'Country'
label = 'Country (usually with recognized iso-code)'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'marinecountry' stratum = '6' parentcat = 'global'
title = 'Country incl maritime area'
label = 'Country incl maritime area (usually with recognized iso-code)'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'continentcountry' stratum = '6' parentcat = 'subcontinent'
title = 'Country, or part of country, falling within one of the classical 7 continents'
label = 'Transcontinental countries are split into parts'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'marinecontinentcountry' stratum = '6' parentcat = 'marinesubcontinent'
title = 'Country, or part of country, falling within one of the classical 7 continents'
label = 'Transcontinental countries are split into parts'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'state' stratum = '7' parentcat = 'country'
title = 'State'
label = 'State as part of a country (countries with no states are set to country = state)'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'province' stratum = '8' parentcat = 'state'
title = 'Province within a country'
label = 'Provinces as part of a state'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'district' stratum = '9' parentcat = 'province'
title = 'District within Province'
label = 'District is an arbitrary political division used for designating regions within a province'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'community' stratum = '10' parentcat = 'district'
title = 'Community within dstrict'
label = 'Community is an arbitrary political division used for designating regions within a district'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'quarter' stratum = '11' parentcat = 'community'
title = 'Quarter within community'
label = 'Quarter is an arbitrary division used for designating regions within a community'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'domain' stratum = '12' parentcat = '*'
title = 'Arbitrary spatial extent having any region of categories 0 to 11 as parentid'
label = 'User defined but public region definition'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'tract' stratum = '12' parentcat = '*'
title = 'Tract is a user defined region category (private or public) and can have any region of categories 0 to 11 as parentid'
label = 'Tract is arbitrary defined by users, and can be kept private or made available for public use'>
</parameters>
</process>
<process processid ='regioncategories'>
<overwrite>Y</overwrite>
<delete>N</delete>
<parameters regioncat = 'site' stratum = '13' parentcat = 'tract'
title = 'Site is a user defined region category having tract as parentid'
label = 'Site is arbitrary defined by users'>
</parameters>
</process>
</manageregion>
the above xml file is included in regions_karttur_setup_20181116.txt, and if you set DefaultRegions to True in the main section on setup_process_regions.py (hidden above) and run the script, the default region categories will be added to the Framework.
Adding default regions
Default regions (at stratum 1 to 11) can be added using either a rectangular area defined from the corner points or from existing polygons. The Framework comes with two types of default regions: arbitrary (rectangular) default regions, and the world’s continents and countries in two different formats (bounded by the land-sea shoreline and including marine areas). If you run the module setup_process_regions.py with DefaultRegions set to True all the default arbitrary regions as well as both formats of global continents and countries are added.
Arbitrary default regions
The Framework comes with the option to define a number of (arbitrary) default regions, including for tropical, subtropical, temperate and arctic regions. You do not need to add these regions unless you intend to work with them.
The pre-defined arbitrary regions also include a special region, trmm, that coincide with the global rainfall estimates from the Tropical Rainfall Measusrement Missions (TRMM) mission. If you intend to use the TRMM rainfall data, please make sure that you add the trmm region.
All the arbitrary regions are defined from corner coordinates and are added to the Framework with the process defaultregion.
The Framework contains cleaned and prepared datasets for:
global countries (country)
global countries per continent (continentcountry)
continental sub-Regions (subcontinent)
continents (contient)
marine countries (marinecountry)
marine continent countries (marinecontinentcountry)
marine continents (marinecontinent)
marine continent subregions (marinesubcontinent)
The first four are based on the 2014 national boundaries with polygons at high spatial resolution following the coastline. The last four “marine” versions include the maritime area. The latter polygons are thus guaranteed to contain all coastal and near-shore areas. Before converting the datasets to default regions you must import them as ancillary layers using the process organizeancillary.
With the polygon data imported, you can convert the content to default regions with the process defaultregionfromvector. In order for that to work, the attribute table of the polygons must contain the following pre-defined columns:
The module setup_process_regions.py also contains options for installing and defining system layers and data, including for:
MODIS
Landsat
Sentinel
Ancillary
Climate
In the main section of setup_process_regions.py, change the boolean variable defining whether to install the feature you are interested to True and run the module.
If you intend to use the Framework for calculations with any satellite data, you need to setup either the MODIS or Sentinel systems (or both).