Beispiel #1
0
    def drawSubGiMap(self, idx, bufferWidth, bufferHeight, bmp):
        """
        Draw two relative Gi* maps for current Gi* map
        """
        dc = wx.BufferedDC(None, bmp)
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.DrawRectangle(0, 0, bufferWidth, bufferHeight)

        if not "Linux" in stars.APP_PLATFORM:
            # not good drawing effect using GCDC in linux
            dc = wx.GCDC(dc)

        view = View2ScreenTransform(self.extent, bufferWidth, bufferHeight)

        p_values = self.space_gstar[idx]
        z_values = self.space_gstar_z[idx]

        not_sig = list(np.where(p_values > 0.05)[0])
        sig = set(np.where(p_values <= 0.05)[0])
        hotspots = list(sig.intersection(set(np.where(z_values >= 0)[0])))
        coldspots = list(sig.intersection(set(np.where(z_values < 0)[0])))
        id_groups = [not_sig, hotspots, coldspots]

        from stars.visualization.maps.BaseMap import PolygonLayer
        draw_layer = PolygonLayer(self, self.layer, build_spatial_index=False)
        #edge_clr = wx.Colour(200,200,200, self.opaque)
        edge_clr = self.color_schema_dict[self.layer.name].edge_color
        draw_layer.set_edge_color(edge_clr)
        draw_layer.set_data_group(id_groups)
        draw_layer.set_fill_color_group(self.gi_color_group)
        draw_layer.draw(dc, view)

        return bmp
Beispiel #2
0
    def drawSubView(self, lisa_idx, bufferWidth, bufferHeight, bmp):
        dc = wx.BufferedDC(None, bmp)
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.DrawRectangle(0, 0, bufferWidth, bufferHeight)

        if not "Linux" in stars.APP_PLATFORM:
            # not good drawing effect using GCDC in linux
            dc = wx.GCDC(dc)

        view = View2ScreenTransform(self.extent, bufferWidth, bufferHeight)

        ml = self.moran_locals[lisa_idx]
        # 0 not significant, 1 HH, 2 LL, 3 LH, 4 HL, 5 Neighborless
        sigFlag = ml[2]
        clusterFlag = ml[3]
        lm_sig = np.array(sigFlag)
        lm_q = np.array(clusterFlag)

        id_groups = [[] for i in range(6)]
        for i, sig in enumerate(lm_sig):
            if sig > 0:
                id_groups[lm_q[i]].append(i)
            else:
                id_groups[0].append(i)

        from stars.visualization.maps.BaseMap import PolygonLayer
        draw_layer = PolygonLayer(self, self.layer, build_spatial_index=False)
        #edge_clr = wx.WHITE#wx.Colour(200,200,200, self.opaque)
        edge_clr = self.color_schema_dict[self.layer.name].edge_color
        draw_layer.set_edge_color(edge_clr)
        draw_layer.set_data_group(id_groups)
        draw_layer.set_fill_color_group(self.lisa_color_group)
        draw_layer.draw(dc, view)
Beispiel #3
0
    def draw3DMap(self, bmp, idx, bufferWidth, bufferHeight):
        dc = wx.BufferedDC(None, bmp)
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.DrawRectangle(0, 0, bufferWidth, bufferHeight)

        if not "Linux" in stars.APP_PLATFORM:
            # not good drawing effect using GCDC in linux
            dc = wx.GCDC(dc)

        view = View2ScreenTransform(self.extent, bufferWidth, bufferHeight)
        view.zoom_extent = self.map_query_region
        subBmpHeight = self.bufferHeight / self.t
        ratio = bufferHeight / float(subBmpHeight)
        from stars.visualization.maps.BaseMap import PolygonLayer
        draw_layer = PolygonLayer(self, self.layer, build_spatial_index=False)

        p_values = self.space_gstar[idx]
        z_values = self.space_gstar_z[idx]

        not_sig = list(np.where(p_values > 0.05)[0])
        sig = set(np.where(p_values <= 0.05)[0])
        hotspots = list(sig.intersection(set(np.where(z_values >= 0)[0])))
        coldspots = list(sig.intersection(set(np.where(z_values < 0)[0])))
        id_groups = [not_sig, hotspots, coldspots]

        self.id_groups = id_groups
        draw_layer.set_data_group(id_groups)
        draw_layer.set_fill_color_group(self.gi_color_group)
        draw_layer.set_edge_color(stars.DEFAULT_MAP_EDGE_COLOR)

        edge_clr = wx.Colour(200, 200, 200, self.opaque)
        draw_layer.set_edge_color(edge_clr)
        draw_layer.draw(dc, view, draw3D=ratio)
Beispiel #4
0
 def drawSubLISA(self, lisa_idx, bufferWidth, bufferHeight,bmp):
     """
     Draw two relative LISA maps for current Markov LISA map
     """
     dc = wx.BufferedDC(None, bmp)
     dc.SetBrush(wx.WHITE_BRUSH)
     dc.SetPen(wx.TRANSPARENT_PEN)
     dc.DrawRectangle(0,0,bufferWidth,bufferHeight)
     
     if not "Linux" in stars.APP_PLATFORM:
         # not good drawing effect using GCDC in linux
         dc = wx.GCDC(dc)
     
     view = View2ScreenTransform(
         self.extent, 
         bufferWidth, 
         bufferHeight
         ) 
     
     lm = self.moran_locals[lisa_idx]
     # 0 not significant, 1 HH, 2 LL, 3 LH, 4 HL, 5 Neighborless
     try:
         # LISA from c++ DLL call
         localMoran, sigLocalMoran, sigFlag, clusterFlag = lm
         lm_moran = np.array(localMoran)
         lm_p_sim = np.array(sigLocalMoran)
         lm_sig = np.array(sigFlag)
         lm_q = np.array(clusterFlag)
         candidates = np.where(lm_sig<1)[0]
         id_groups = []
         id_groups.append(list(candidates))
         for i in range(1,n):
             cluster = set(np.where(lm_q==i)[0]) - set(candidates)
             id_groups.append(cluster)
     except:
         # LISA from Pysal call
         sigFlag = lm[2]
         clusterFlag = lm[3]
         lm_sig = np.array(sigFlag)
         lm_q = np.array(clusterFlag)
         id_groups = [[] for i in range(6)]
         for i,sig in enumerate(lm_sig):
             if sig > 0:
                 id_groups[lm_q[i]].append(i)
             else:
                 id_groups[0].append(i)
         
     from stars.visualization.maps.BaseMap import PolygonLayer
     draw_layer = PolygonLayer(self, self.layer, build_spatial_index=False)
     #edge_clr = wx.Colour(200,200,200, self.opaque)
     edge_clr = self.color_schema_dict[self.layer.name].edge_color
     draw_layer.set_edge_color(edge_clr)
     draw_layer.set_data_group(id_groups)
     lisa_color_group = [self.NOT_SIG_color,self.HH_color,self.LL_color,
                         self.LH_color,self.HL_color,self.OBSOLETE_color]
     draw_layer.set_fill_color_group(lisa_color_group)
     draw_layer.draw(dc, view)        
     
     return bmp
Beispiel #5
0
    def drawSubLISA(self, lisa_idx, bufferWidth, bufferHeight, bmp):
        """
        Draw two relative LISA maps for current Markov LISA map
        """
        dc = wx.BufferedDC(None, bmp)
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.DrawRectangle(0, 0, bufferWidth, bufferHeight)

        if not "Linux" in stars.APP_PLATFORM:
            # not good drawing effect using GCDC in linux
            dc = wx.GCDC(dc)

        view = View2ScreenTransform(self.extent, bufferWidth, bufferHeight)

        lm = self.moran_locals[lisa_idx]
        # 0 not significant, 1 HH, 2 LL, 3 LH, 4 HL, 5 Neighborless
        try:
            # LISA from c++ DLL call
            localMoran, sigLocalMoran, sigFlag, clusterFlag = lm
            lm_moran = np.array(localMoran)
            lm_p_sim = np.array(sigLocalMoran)
            lm_sig = np.array(sigFlag)
            lm_q = np.array(clusterFlag)
            candidates = np.where(lm_sig < 1)[0]
            id_groups = []
            id_groups.append(list(candidates))
            for i in range(1, n):
                cluster = set(np.where(lm_q == i)[0]) - set(candidates)
                id_groups.append(cluster)
        except:
            # LISA from Pysal call
            sigFlag = lm[2]
            clusterFlag = lm[3]
            lm_sig = np.array(sigFlag)
            lm_q = np.array(clusterFlag)
            id_groups = [[] for i in range(6)]
            for i, sig in enumerate(lm_sig):
                if sig > 0:
                    id_groups[lm_q[i]].append(i)
                else:
                    id_groups[0].append(i)

        from stars.visualization.maps.BaseMap import PolygonLayer
        draw_layer = PolygonLayer(self, self.layer, build_spatial_index=False)
        #edge_clr = wx.Colour(200,200,200, self.opaque)
        edge_clr = self.color_schema_dict[self.layer.name].edge_color
        draw_layer.set_edge_color(edge_clr)
        draw_layer.set_data_group(id_groups)
        lisa_color_group = [
            self.NOT_SIG_color, self.HH_color, self.LL_color, self.LH_color,
            self.HL_color, self.OBSOLETE_color
        ]
        draw_layer.set_fill_color_group(lisa_color_group)
        draw_layer.draw(dc, view)

        return bmp
Beispiel #6
0
 def draw_space_in_buffer(self, space_shp, width=6000,height=6000):
     """
     Function for fast space-time query: how many points
     sit in each polygon
     """
     from stars.visualization.maps.BaseMap import PolygonLayer
     from stars.visualization.utils import View2ScreenTransform,DrawPurePoints
     # specify different color for each polygon
     poly_color_dict = {}
     n = len(space_shp)
     
     if n > 10000:
         width = 9000
         height = 9000
     
     id_group = []
     color_group = []
     color_range = 254*254*254 - 1
     used_color = {}
     for i in range(n):
         color_idx = random.randint(1,color_range)
         while color_idx in used_color: 
             color_idx = random.randint(1,color_range)
         used_color[color_idx] = True
         r = color_idx & 255
         g = (color_idx>>8) & 255
         b = (color_idx>>16) & 255
         id_group.append([i])
         color_group.append(wx.Color(r,g,b))
         poly_color_dict[(r,g,b)] = i
         
     # draw polygon to an empty_buffer
     polygon_layer = PolygonLayer(self, space_shp)
     polygon_layer.set_edge_color(wx.Color(0,0,0,0))
     polygon_layer.set_data_group(id_group)
     polygon_layer.set_fill_color_group(color_group)
     #polygon_layer.set_edge_color_group(color_group)
     
     view = View2ScreenTransform(space_shp.extent, width, height)
     buffer = wx.EmptyBitmap(width, height)
     dc = wx.BufferedDC(None, buffer)
     dc.Clear()
     polygon_layer.draw(dc, view, drawRaw=True)
     
     """
     _points = []
     for p in points: 
         x,y = view.view_to_pixel(p[0],p[1])
         x,y = int(round(x)), int(round(y))
         _points.append((x,y))
     DrawPurePoints(dc, _points)
     """
     bmp = wx.ImageFromBitmap(buffer)
     #buffer.SaveFile('test.bmp',wx.BITMAP_TYPE_BMP)
     return bmp,view,poly_color_dict
Beispiel #7
0
 def drawSubLISAMap(self, idx, bufferWidth, bufferHeight,bmp):
     """
     Draw two relative LISa maps for current LISA map
     """
     dc = wx.BufferedDC(None, bmp)
     dc.SetBrush(wx.WHITE_BRUSH)
     dc.SetPen(wx.TRANSPARENT_PEN)
     dc.DrawRectangle(0,0,bufferWidth,bufferHeight)
     
     if not "Linux" in stars.APP_PLATFORM:
         # not good drawing effect using GCDC in linux
         dc = wx.GCDC(dc)
     
     view = View2ScreenTransform(
         self.extent, 
         bufferWidth, 
         bufferHeight
         ) 
     
     moran_local = self.space_moran_locals[idx]
     sigFlag     = moran_local[2]
     clusterFlag = moran_local[3]
     lm_sig      = np.array(sigFlag)
     lm_q        = np.array(clusterFlag)
     id_groups   = [[] for i in range(6)]
     # 0 not significant, 1 HH, 2 LL, 3 LH, 4 HL, 5 Neighborless
     for i,sig in enumerate(lm_sig):
         if sig > 0:
             id_groups[lm_q[i]].append(i)
         else:
             id_groups[0].append(i)
     
     from stars.visualization.maps.BaseMap import PolygonLayer
     draw_layer = PolygonLayer(self, self.layer, build_spatial_index=False)
     #edge_clr = wx.Colour(200,200,200, self.opaque)
     edge_clr = self.color_schema_dict[self.layer.name].edge_color
     draw_layer.set_edge_color(edge_clr)
     draw_layer.set_data_group(id_groups)
     draw_layer.set_fill_color_group(self.lisa_color_group)
     draw_layer.draw(dc, view)        
     
     return bmp
Beispiel #8
0
    def drawSubGiMap(self, idx, bufferWidth, bufferHeight,bmp):
        """
        Draw two relative Gi* maps for current Gi* map
        """
        dc = wx.BufferedDC(None, bmp)
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.DrawRectangle(0,0,bufferWidth,bufferHeight)

        if not "Linux" in stars.APP_PLATFORM:
            # not good drawing effect using GCDC in linux
            dc = wx.GCDC(dc)

        view = View2ScreenTransform(
            self.extent,
            bufferWidth,
            bufferHeight
            )

        p_values = self.space_gstar[idx]
        z_values = self.space_gstar_z[idx]

        not_sig = list(np.where(p_values>0.05)[0])
        sig     = set(np.where(p_values<=0.05)[0])
        hotspots = list(sig.intersection(set(np.where(z_values>=0)[0])) )
        coldspots = list(sig.intersection(set(np.where(z_values<0)[0])) )
        id_groups = [not_sig,hotspots,coldspots]

        from stars.visualization.maps.BaseMap import PolygonLayer
        draw_layer = PolygonLayer(self, self.layer, build_spatial_index=False)
        #edge_clr = wx.Colour(200,200,200, self.opaque)
        edge_clr = self.color_schema_dict[self.layer.name].edge_color
        draw_layer.set_edge_color(edge_clr)
        draw_layer.set_data_group(id_groups)
        draw_layer.set_fill_color_group(self.gi_color_group)
        draw_layer.draw(dc, view)

        return bmp
Beispiel #9
0
 def draw3DMap(self, bmp, idx, bufferWidth, bufferHeight):
     dc = wx.BufferedDC(None, bmp)
     dc.SetBrush(wx.WHITE_BRUSH)
     dc.SetPen(wx.TRANSPARENT_PEN)
     dc.DrawRectangle(0,0,bufferWidth,bufferHeight)
     
     if not "Linux" in stars.APP_PLATFORM:
         # not good drawing effect using GCDC in linux
         dc = wx.GCDC(dc)
     
     view = View2ScreenTransform(
         self.extent, 
         bufferWidth, 
         bufferHeight
     ) 
     view.zoom_extent = self.map_query_region 
     subBmpHeight = self.bufferHeight / self.t
     ratio = bufferHeight / float(subBmpHeight)
     from stars.visualization.maps.BaseMap import PolygonLayer
     draw_layer = PolygonLayer(self, self.layer, build_spatial_index=False)
     
     p_values = self.space_gstar[idx]
     z_values = self.space_gstar_z[idx]
     
     not_sig = list(np.where(p_values>0.05)[0])
     sig     = set(np.where(p_values<=0.05)[0])
     hotspots = list(sig.intersection(set(np.where(z_values>=0)[0])) )
     coldspots = list(sig.intersection(set(np.where(z_values<0)[0])) )
     id_groups = [not_sig,hotspots,coldspots]
         
     self.id_groups = id_groups
     draw_layer.set_data_group(id_groups)
     draw_layer.set_fill_color_group(self.gi_color_group)
     draw_layer.set_edge_color(stars.DEFAULT_MAP_EDGE_COLOR)
     
     edge_clr = wx.Colour(200,200,200, self.opaque)
     draw_layer.set_edge_color(edge_clr)
     draw_layer.draw(dc, view, draw3D=ratio)