Beispiel #1
0
 def axis(self, limits=None, lonlat=True):
     """
     Sets the min and max of the x and y map axes, with ``[xmin, xmax, ymin, ymax]`` .
     
     :param limits: (*list*) Min and max of the x and y map axes.
     :param lonlat: (*boolean*) Is longitude/latitude or not.
     """
     if limits is None:
         self.axes.setDrawExtent(self.axes.getMapView().getExtent())
         self.axes.setExtent(self.axes.getDrawExtent().clone())
         return True
     else:
         if len(limits) == 4:
             xmin = limits[0]
             xmax = limits[1]
             ymin = limits[2]
             ymax = limits[3]
             extent = Extent(xmin, xmax, ymin, ymax)
             if lonlat:
                 self.axes.setLonLatExtent(extent)
                 self.axes.setExtent(self.axes.getDrawExtent().clone())
             else:
                 self.axes.setDrawExtent(extent)
                 self.axes.setExtent(extent)
             return True
         else:
             print 'The limits parameter must be a list with 4 elements: xmin, xmax, ymin, ymax!'
             return None
mapFrame.addLayer(cityLayer)

#---- Add South China Sea
aMapFrame = MapFrame()
aLayoutMap = LayoutMap(aMapFrame)
aLayoutMap.setDrawGridLabel(False)
aLayoutMap.setDrawGridTickLine(False)
aLayoutMap.setLeft(40)
aLayoutMap.setTop(350)
aLayoutMap.setWidth(85)
aLayoutMap.setHeight(109)
mapLayout.addElement(aLayoutMap)
aMapFrame.addLayer(bou1Layer_1)
aProjInfo = ProjectionInfo("+proj=lcc+lat_1=25+lat_2=47+lon_0=105")
aMapFrame.getMapView().projectLayers(aProjInfo)
aMapFrame.getMapView().zoomToExtentLonLatEx(Extent(106.5,122.5,1,23))

#---- Project mapview
print 'Project mapview...'
projStr = '+proj=lcc+lat_1=25+lat_2=47+lon_0=105'
projInfo = ProjectionInfo(projStr)
mapView.projectLayers(projInfo)
extent = Extent(78,130,15,53)
mapView.zoomToExtentLonLatEx(extent)

#---- Create MeteoDataInfo object
mdi = MeteoDataInfo()

#---- Set start/end time
stime = datetime(2010,10,14,14)
etime = datetime(2010,10,14,20)
vdata = mdi.getGridData('V')

#---- Create wind vector layer from the U/V grid data
layer = DrawMeteoData.createGridVectorLayer(udata, vdata,  'UV_Vector', True)
#layer = DrawMeteoData.createGridBarbLayer(udata, vdata,  'UV_Barb', True)
#layer = DrawMeteoData.createStreamlineLayer(udata, vdata, 'Z_Streamline', True)

#---- Add layer
mapFrame.addLayer(layer)

#--- Move pressure layer to bottom
mapFrame.moveLayer(layer, 0)

#---- Add title
title = mapLayout.addText('MeteoInfo script demo', 350, 30, 'Arial', 16)

#---- Add wind arrow
windArrow = mapLayout.addWindArrow(660, 420)

#---- Zoom layout map
print 'Zoom layout map...'
mapLayout.getActiveLayoutMap().zoomToExtentLonLatEx(Extent(70, 140, 15, 55))

#---- Set mapframe
mapFrame.setGridXDelt(10)
mapFrame.setGridYDelt(10)

frame = JFrame('MeteoInfo Script Sample', size = (800, 600))
frame.add(mapLayout)
frame.visible = True
print 'Finished!'
Beispiel #4
0
#---- Create pressure shaded layer
print 'Create pressure shaded layer...'
pressLayer = DrawMeteoData.createShadedLayer(gdata, 'Pressure', 'PS', True)

#---- Add layer
mapFrame.addLayer(pressLayer)

#--- Move pressure layer to bottom
mapFrame.moveLayer(pressLayer, 0)

#---- Add title
title = mapLayout.addText('MeteoInfo script demo', 350, 30, 'Arial', 16)

#---- Zoom layout map
print 'Zoom layout map...'
mapLayout.getActiveLayoutMap().zoomToExtentLonLatEx(Extent(0, 360, -90, 90))

#---- Set mapframe
mapFrame.setGridXDelt(30)
mapFrame.setGridYDelt(30)

#---- Add legend
legend = mapLayout.addLegend(150, 440)
legend.setLegendStyle(LegendStyles.Bar_Horizontal)
legend.setLegendLayer(pressLayer)

#---- Output figure
print 'Output figure...'
mapLayout.paintGraphics()
mapLayout.exportToPicture(os.path.join(figDir, 'pressure_test.ps'))
Beispiel #5
0
#---- Add layer
mapFrame.addLayer(pressLayer)

#--- Move pressure layer to bottom
mapFrame.moveLayer(pressLayer, 0)

#---- Add title
title = mapLayout.addText('MeteoInfo script demo - Lambert projection', 350, 30, 'Arial', 16)

#---- Project mapview
print 'Project mapview...'
projStr = '+proj=lcc +lat_1=30 +lat_2=60 +lat_0=0 +lon_0=110'
projInfo = ProjectionInfo(projStr)
mapFrame.getMapView().projectLayers(projInfo)
extent = Extent(78, 130, 15, 53)
mapFrame.getMapView().zoomToExtentLonLatEx(extent)

#---- Set mapframe
mapFrame.setDrawNeatLine(True)
mapFrame.setDrawGridLine(True)
mapFrame.setDrawGridLabel(True)
mapFrame.setGridLabelPosition(GridLabelPosition.LeftBottom)
mapFrame.setGridXDelt(10)
mapFrame.setGridYDelt(10)

#---- Add legend
legend = mapLayout.addLegend(150, 440)
legend.setLegendStyle(LegendStyles.Bar_Horizontal)
legend.setLegendLayer(pressLayer)