meta data for this page

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tectonicwaters:gplates_coloring_features_by_absolute_age [2017/01/09 16:01] – readmore christiantectonicwaters:gplates_coloring_features_by_absolute_age [2019/08/24 09:06] (current) – Discussion status changed christian
Line 12: 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 here:+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_reconstruction0ma.png?nolink |StaticPolygons filled by GTS2012 colours - Reconstruction at 0 Ma}} +{{gallery>:tectonicwaters?gplates20_colorbyproperty_gts-absage_reconstruction*ma.png?200x200&lightbox&cache}} 
-{{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}} +==== Update ==== 
-{{gallery>:tectonicwaters:gplates20_colorbyproperty_gts-absage_reconstruction150ma.png?nolink |StaticPolygons filled by GTS2012 colours - Reconstruction at 150 Ma}}+ 
 +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. 
 +Seehttp://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> 
 + 
 + 
 +==== Color by property ==== 
 + 
 +Copy the file below into your GPlates user script directory.
  
 <file python ColorByProperty.py> <file python ColorByProperty.py>
Line 77: 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~~