Пример #1
0
	def __init__(self, parent=None):
		WorldClimQueryLayout.__init__ ( self, parent )
		self.about = Description()
		
		self.SetIcon(wx.Icon(GenGIS.mainWindow.GetExeDir() + "images/CrazyEye.ico", wx.BITMAP_TYPE_ICO))
		
		# check if projections exist. UTM format with no projection is not convertible
		# into Lat/Lon coordinates, which are needed for Pybioclim
		geographic = GenGIS.StudyController.IsUsingGeographic(GenGIS.study.GetController())
		projected = GenGIS.StudyController.IsUsingProjection(GenGIS.study.GetController())
		if(not (geographic or projected)):
			wx.MessageBox("The current map has an unrecognised projection. Unfortunately at this time UTM data can not be used with this plugin if the map's projection is unknown.","Improper Coordinate System")
			self.Close()
			return
		
		# check required data has been loaded (doesn't need sequences)
		if GenGIS.layerTree.GetNumMapLayers() == 0 or GenGIS.layerTree.GetNumLocationSetLayers() == 0:
			wx.MessageBox("This plugin requires map and location data to be loaded.", "Additional data required.")
			self.Close()
			return
		
		#populate measure wxChoice
		for key in sorted( self.fileTranslations.iterkeys() ):
			self.m_Measures.Append(key)
		self.m_Measures.SetSelection(0)
		
		file = self.fileTranslations[ self.m_Measures.GetStringSelection() ]
		pybioclim.get_dataset( file.lower() )
		
		#get descriptions for maps
		desc = {}
		desc = pybioclim.metadata['%s.bil' %file.lower()] 
		self.MAX = desc["maxvalue"]
		self.MIN = desc["minvalue"]
		self.UpdateDescription( file.lower(), desc )
Пример #2
0
	def OnMeasureChanged(self, event):
		file = self.fileTranslations[ self.m_Measures.GetStringSelection() ]
		pybioclim.get_dataset( file.lower() )
		
		#get descriptions for maps
		desc = {}
		desc = pybioclim.metadata['%s.bil' %file.lower()]
		self.MAX = desc["maxvalue"]
		self.MIN = desc["minvalue"]
		self.UpdateDescription( file.lower(), desc )
Пример #3
0
    def OnMeasureChanged(self, event):
        file = self.fileTranslations[self.m_Measures.GetStringSelection()]
        pybioclim.get_dataset(file.lower())

        #get descriptions for maps
        desc = {}
        desc = pybioclim.metadata['%s.bil' % file.lower()]
        self.MAX = desc["maxvalue"]
        self.MIN = desc["minvalue"]
        self.UpdateDescription(file.lower(), desc)
Пример #4
0
    def __init__(self, parent=None):
        WorldClimQueryLayout.__init__(self, parent)

        self.GetFileTranslations()
        self.about = Description()

        self.SetIcon(
            wx.Icon(GenGIS.mainWindow.GetExeDir() + "images/CrazyEye.ico",
                    wx.BITMAP_TYPE_ICO))

        # check if projections exist. UTM format with no projection is not convertible
        # into Lat/Lon coordinates, which are needed for Pybioclim
        geographic = GenGIS.StudyController.IsUsingGeographic(
            GenGIS.study.GetController())
        projected = GenGIS.StudyController.IsUsingProjection(
            GenGIS.study.GetController())
        if (not (geographic or projected)):
            wx.MessageBox(
                "The current map has an unrecognised projection. Unfortunately at this time UTM data can not be used with this plugin if the map's projection is unknown.",
                "Improper Coordinate System")
            self.Close()
            return

        # check required data has been loaded (doesn't need sequences)
        if GenGIS.layerTree.GetNumMapLayers(
        ) == 0 or GenGIS.layerTree.GetNumLocationSetLayers() == 0:
            wx.MessageBox(
                "This plugin requires map and location data to be loaded.",
                "Additional data required.")
            self.Close()
            return

        #populate measure wxChoice
        for key in sorted(self.fileTranslations.iterkeys()):
            self.m_Measures.Append(key)
        self.m_Measures.SetSelection(0)

        file = self.fileTranslations[self.m_Measures.GetStringSelection()]
        pybioclim.get_dataset(file.lower())

        #get descriptions for maps
        desc = {}
        desc = pybioclim.metadata['%s.bil' % file.lower()]
        self.MAX = desc["maxvalue"]
        self.MIN = desc["minvalue"]
        self.UpdateDescription(file.lower(), desc)
Пример #5
0
    def OnCalculate(self, event):
        wx.BeginBusyCursor()

        self.txtLog.AppendText('Retrieving ' +
                               self.m_Measures.GetStringSelection() +
                               ' data...\n')

        #	activeLocLayers = GenGIS.layerTree.GetLocationSetLayer(0).GetAllActiveLocationLayers()
        activeLocLayers = GenGIS.layerTree.GetLocationSetLayer(
            0).GetAllLocationLayers()
        lat_lon = []
        for locLayer in activeLocLayers:
            if 'Latitude' in locLayer.GetController().GetData().keys():
                lat = float(locLayer.GetController().GetData()['Latitude'])
                lon = float(locLayer.GetController().GetData()['Longitude'])

            else:
                lon = locLayer.GetController().GetEasting()
                lat = locLayer.GetController().GetNorthing()
                geo = GenGIS.GeoCoord(lon, lat)
                point = GenGIS.Point3D()
                GenGIS.layerTree.GetMapLayer(0).GetController().GeoToGrid(
                    geo, point)
                GenGIS.layerTree.GetMapLayer(0).GetController().GridToGeo(
                    point, geo)
                lon = geo.longitude
                lat = geo.latitude

            lat_lon.append((lat, lon))
        # GETS SOME FORM OF DATA
        dataSet = self.fileTranslations[
            self.m_Measures.GetStringSelection()].lower()
        dat = pybioclim.get_dataset(dataSet)
        array = dat.ReadAsArray()
        values = pybioclim.get_values(dataSet, lat_lon)
        metadata = []
        for val in values:
            index = values.index(val)

            #check if val is NODATA. Needed for MAC as SetNoData() is not supported under GDAL 1.5.0
            if (val > int(self.MAX)) or (val < int(self.MIN)):
                val = None
            tem = str(val)
            metadata.append(tem)
            self.txtLog.AppendText('For ' + activeLocLayers[index].GetName() +
                                   ' adding data: ' + tem + '.\n')

        # ADD DATA BACK TO LOCATIONS METADATA
        GenGIS.layerTree.GetLocationSetLayer(0).GetController().AddMetadata(
            str(self.m_Measures.GetStringSelection()), metadata)

        self.txtLog.AppendText(
            '\n' + self.m_Measures.GetStringSelection() +
            ' results added to location metadata table as "' +
            str(self.m_Measures.GetStringSelection()) + '".\n\n')

        wx.EndBusyCursor()
Пример #6
0
	def OnCalculate(self, event):
		wx.BeginBusyCursor()
		
		self.txtLog.AppendText('Retrieving ' + self.m_Measures.GetStringSelection() + ' data...\n')
		
	#	activeLocLayers = GenGIS.layerTree.GetLocationSetLayer(0).GetAllActiveLocationLayers()
		activeLocLayers = GenGIS.layerTree.GetLocationSetLayer(0).GetAllLocationLayers()
		lat_lon = []
		for locLayer in activeLocLayers:
			if 'Latitude' in locLayer.GetController().GetData().keys():
				lat = float(locLayer.GetController().GetData()['Latitude'])
				lon = float(locLayer.GetController().GetData()['Longitude'])
			
			else:
				lon = locLayer.GetController().GetEasting()
				lat = locLayer.GetController().GetNorthing()
				geo = GenGIS.GeoCoord(lon,lat)
				point = GenGIS.Point3D()
				GenGIS.layerTree.GetMapLayer(0).GetController().GeoToGrid( geo, point)
				GenGIS.layerTree.GetMapLayer(0).GetController().GridToGeo( point, geo)
				lon = geo.longitude;
				lat = geo.latitude;
				
				
			lat_lon.append( (lat,lon) )
		# GETS SOME FORM OF DATA
		dataSet = self.fileTranslations[ self.m_Measures.GetStringSelection() ].lower()
		dat = pybioclim.get_dataset(dataSet)
		array = dat.ReadAsArray()
		values = pybioclim.get_values(dataSet,lat_lon)
		metadata = []
		for val in values:
			index = values.index(val)
			
			#check if val is NODATA. Needed for MAC as SetNoData() is not supported under GDAL 1.5.0
			if (val > int(self.MAX)) or (val < int(self.MIN)):
				val = None
			tem = str(val)
			metadata.append(tem)
			self.txtLog.AppendText('For ' + activeLocLayers[index].GetName() + ' adding data: ' + tem + '.\n')
			
		# ADD DATA BACK TO LOCATIONS METADATA
		GenGIS.layerTree.GetLocationSetLayer(0).GetController().AddMetadata( str(self.m_Measures.GetStringSelection()) , metadata )
		
		self.txtLog.AppendText('\n' + self.m_Measures.GetStringSelection() + ' results added to location metadata table as "' + str(self.m_Measures.GetStringSelection()) + '".\n\n')
		
		wx.EndBusyCursor()