meta data for this page

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tectonicwaters:gplates_coloring_features_by_absolute_age [2017/01/09 15:59] – created christiantectonicwaters:gplates_coloring_features_by_absolute_age [2019/08/24 09:06] (current) – Discussion status changed christian
Line 4: Line 4:
  
 When making reconstructions in [[http://www.gplates.org|GPlates]] one often wants to colour features by their geological age. Using the [[https://bitbucket.org/chhei/gmt-cpts|colour scheme of the Geological Time Scale]] is a way accepted by the community to associate absolute (and stratigraphic) ages with colour. When reconstructing data in GPlates using the default ''FeatureAge'' option for styling, however, features "grow older" as the colouring is applied relative to age of the feature, depending on reconstruction age. As most geoscientists are cognitively tuned to more static maps, changing colours with age can be quite confusing. Here's a recipe to maintain constant or "absolute" age colouring in GPlates when reconstructing data.  When making reconstructions in [[http://www.gplates.org|GPlates]] one often wants to colour features by their geological age. Using the [[https://bitbucket.org/chhei/gmt-cpts|colour scheme of the Geological Time Scale]] is a way accepted by the community to associate absolute (and stratigraphic) ages with colour. When reconstructing data in GPlates using the default ''FeatureAge'' option for styling, however, features "grow older" as the colouring is applied relative to age of the feature, depending on reconstruction age. As most geoscientists are cognitively tuned to more static maps, changing colours with age can be quite confusing. Here's a recipe to maintain constant or "absolute" age colouring in GPlates when reconstructing data. 
 +
 +=====  =====
  
 This workaround requires to have the ''ColorByProperty.py'' script installed in the GPlates User directory so that it is available to the GPlates ''Draw Style'' editor. You will also need a color palette file (''*.cpt'') with the Geological Time Scale 2012 colours in [[http://gmt.soest.hawaii.edu|GMT]] format which you can download from my [[https://bitbucket.org/chhei/gmt-cpts/src|BitBucket repository]]. The required file is called [[https://bitbucket.org/chhei/gmt-cpts/src/670c5dcedb4f5f6dee9d4c38a8597c8ac3f87e70/GTS2012/GTS2012_stages.cpt?at=master|''GTS2012_stages.cpt'']]. This workaround requires to have the ''ColorByProperty.py'' script installed in the GPlates User directory so that it is available to the GPlates ''Draw Style'' editor. You will also need a color palette file (''*.cpt'') with the Geological Time Scale 2012 colours in [[http://gmt.soest.hawaii.edu|GMT]] format which you can download from my [[https://bitbucket.org/chhei/gmt-cpts/src|BitBucket repository]]. The required file is called [[https://bitbucket.org/chhei/gmt-cpts/src/670c5dcedb4f5f6dee9d4c38a8597c8ac3f87e70/GTS2012/GTS2012_stages.cpt?at=master|''GTS2012_stages.cpt'']].
Line 10: Line 12:
   - Now, copy the below file ''ColorByProperty.py'' as Python script to that directory. Make sure to use a proper text editor, such as [[https://notepad-plus-plus.org/|Notepad++ on Windows]] when dealing with such scripts.   - Now, copy the below file ''ColorByProperty.py'' as Python script to that directory. Make sure to use a proper text editor, such as [[https://notepad-plus-plus.org/|Notepad++ on Windows]] when dealing with such scripts.
   - Close GPlates   - Close GPlates
-  - In your GIS application of choice, open the shapefile containing the feature collection which you want to colour and add a new attribute column. As example, I am using [[http://qgis.org|QGIS]] and the ''StaticPolygons'' feature collection from the GPlates Sample Data collection (''SampleData'' -> ''FeatureCollections'' -> ''StaticPolygons'' -> ''Shapefile'' -> ''Muller_etal_AREPS_2016_StaticPolygons.shp''). I create a new column called ''absage'' which is calculated as new field (Type ''real'').{{ :tectonicwaters:qgis_createnewfield_fieldcalculator_absage-gplates.png?nolink |Creating a new field using QGIS' Field Calculator}}+  - In your GIS application of choice, open the shapefile containing the feature collection which you want to colour and add a new attribute column. As example, I am using [[http://qgis.org|QGIS]] and the ''StaticPolygons'' feature collection from the GPlates Sample Data collection (''SampleData'' -> ''FeatureCollections'' -> ''StaticPolygons'' -> ''Shapefile'' -> ''Muller\_etal\_AREPS\_2016\_StaticPolygons.shp''). I create a new column called ''absage'' which is calculated as new field (Type ''real'').{{ :tectonicwaters:qgis_createnewfield_fieldcalculator_absage-gplates.png?nolink |Creating a new field using QGIS' Field Calculator}}
   - Open GPlates again, load your feature collections   - Open GPlates again, load your feature collections
   - In the GPlates Layers window, click on ''Set Draw style'' for the layer you would like to change the styling of. ''ColorByProperty'' should now be listed as method in the list of styling methods on the left. {{ :tectonicwaters:gplates20_colorbyproperty_gts-absage.png?nolink |Color by property as styling method in the Draw Styles manager in GPlates}}   - In the GPlates Layers window, click on ''Set Draw style'' for the layer you would like to change the styling of. ''ColorByProperty'' should now be listed as method in the list of styling methods on the left. {{ :tectonicwaters:gplates20_colorbyproperty_gts-absage.png?nolink |Color by property as styling method in the Draw Styles manager in GPlates}}
-  - Finally, add a ''Configuration Name'', select the ''palette'' (this is the GTS2012 cpt file you downloaded) and as ''property_name'' put ''gpml:shapefileAttributes:absage''. The last part of the ''property_name'' needs to be the exact attribute name you have created in the shapefile above.+  - Finally, add a ''Configuration Name'', select the ''palette'' (this is the GTS2012 cpt file you downloaded) and as ''property_name'' put ''gpml:shapefileAttributes:absage''. The last part of the ''property\_name'' needs to be the exact attribute name you have created in the shapefile above. 
 + 
 +When you now start reconstructing your feature data, the colouring should remain static at any moment in your reconstruction. See this absolute reconstruction sequence for the western Pacific area at 0, 50, 100 and 150 Ma: 
 + 
 +{{gallery>:tectonicwaters?gplates20_colorbyproperty_gts-absage_reconstruction*ma.png?200x200&lightbox&cache}} 
 + 
 +==== Update ==== 
 + 
 +After [[http://mailman.sydney.edu.au/pipermail/gplates-discuss/2017-January/000583.html|emailing the gplates-discuss mailing list]], [[http://mailman.sydney.edu.au/pipermail/gplates-discuss/2017-January/000584.html|John Cannon provided]] the following, tuned script to use absolute age colouring. This script also needs to be placed in one of the scripts directories (ideally the GPlates default script directory) and simplifies the colouring by absolute age by one step - it is no longer necessary to call the attribute directly as by default the ''FROMAGE'' attribute is used. 
 + 
 +<file python AbsoluteAge.py> 
 +''' 
 +Script sent to gplates-discuss mailinglist by John Cannon on 2017-01-11. 
 +See: http://mailman.sydney.edu.au/pipermail/gplates-discuss/2017-January/000584.html 
 + 
 +''' 
 + 
 +import pygplates 
 + 
 +class AbsoluteAge: 
 + def __init__(self): 
 + pass 
 +  
 + def get_style(self, feature, style): 
 + absolute_age = feature.begin_time() 
 + style.colour = self.cfg['Palette'].get_color(pygplates.PaletteKey(absolute_age)) 
 +  
 + def get_config(self): 
 + self.cfg_dict = {} 
 + self.cfg_dict['Palette/type'] = 'Palette' 
 + return self.cfg_dict 
 +  
 + def set_config(self, config): 
 + self.cfg = config 
 + 
 +  
 +def register(): 
 + pygplates.Application().register_draw_style(AbsoluteAge()) 
 + 
 +</file> 
  
-When you now start reconstructing your feature data, the colouring should remain static at any moment in your reconstruction. See here:+==== Color by property ====
  
-{{gallery>:tectonicwaters:gplates20_colorbyproperty_gts-absage_reconstruction0ma.png?nolink |StaticPolygons filled by GTS2012 colours - Reconstruction at 0 Ma}} +Copy the file below into your GPlates user script directory.
-{{gallery>:tectonicwaters:gplates20_colorbyproperty_gts-absage_reconstruction50ma.png?nolink |StaticPolygons filled by GTS2012 colours - Reconstruction at 50 Ma}} +
-{{gallery>:tectonicwaters:gplates20_colorbyproperty_gts-absage_reconstruction100ma.png?nolink |StaticPolygons filled by GTS2012 colours - Reconstruction at 100 Ma}} +
-{{gallery>:tectonicwaters:gplates20_colorbyproperty_gts-absage_reconstruction150ma.png?nolink |StaticPolygons filled by GTS2012 colours - Reconstruction at 150 Ma}}+
  
 <file python ColorByProperty.py> <file python ColorByProperty.py>
Line 75: Line 114:
 </file> </file>
  
-{{tag> GPlates features colour "plate tectonics" pygplates Python GTS}}+{{tag> GPlates features colour "plate tectonics" pygplates Python GTS tutorial}}
  
  
-~~DISCUSSION~~+~~DISCUSSION:closed~~