Re: [google-appengine] visualization of classification result using color palette

28 views
Skip to first unread message
Message has been deleted

Alex Martelli

unread,
Jul 10, 2017, 5:57:34 AM7/10/17
to google-a...@googlegroups.com
This group is meant for discussion about Google App Engine, the product covered at https://cloud.google.com/appengine/ and links therefrom. Said product is not related to Google Earth Engine. For discussion about the latter, please start at https://productforums.google.com/forum/#!forum/maps .


Thanks,

Alex


On Mon, Jul 10, 2017 at 9:35 AM, Marieke Laengner <laen...@geophysik.uni-kiel.de> wrote:
Hi,

I wrote a script in Google Earth Engine which performs a landuse classification. I gave every class its own color (e.g. urban areas = red). For the web application using Google App Engine I had to translate the javascript script to python and I don't know how to add the color palette to my classification result here. 

The following javascript code worked in GEE:


 // 2) Create colored Classification image
  
  var PALETTE = [
      '#ffffff', // no data
      '#FFFFFF', // clouds
      '#D3D3D3', // Elevated areas (>900m)
      '#87CEFA', // water
      '#9ACD32', // agriculture
      '#006400', // vegetation (cropland and forest)
      '#FFFF00', // Shore areas
      'cc0013', // urban
      '#A52A2A', // bare land
  ].join(',');
  
  var vis_params = {min: 0, max: 8, palette: PALETTE};

Map.addLayer(finalImage, vis_params, 'Landuse classification');


In Google App Engine I tried it like this (the color codes are not the right colors yet, I only put them there to test it):


# 2) Create colored Classification image
  
    PALETTE = ['F0F8FF','FAEBD7','00FFFF', 'F0F8FF', 'FAEBD7', '00FFFF', 'F0F8FF', '00FFFF', '00FFFF',]

  # Visualization
    
    DTCfinal_viz = DTCfinal.getMapId({
          'min': 0,
          'max': 8,
          'palette': 'PALETTE',
          'bands': ','.join(['constant'])
      })
    layers.append({
          'mapid': DTCfinal_viz['mapid'],
          'label': 'DTC final',
          'token': DTCfinal_viz['token']
      })


It doesn't work.

Does someone has an idea how I can color my classification result?

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/629c8d96-f47b-4b9f-8a3e-ee69feb67f3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages