示例#1
0
#colorbar_style = None
#hillshade_style = lbm.HillshadeStyle(azimuth=45,elevation_angle=30, scale=0.1, color_map="copper")
hillshade_style = None
cmap, norm = lbm.cm.from_cpt_city(r"td/DEM_poster")
#cmap = "gist_earth"
tsc = lbm.ThematicStyleColormap(color_map=cmap, vmin=0, vmax=700)
#tsc.color_map = None
style = lbm.GridStyle(color_map_theme=tsc,
                      colorbar_style=colorbar_style,
                      line_style=None,
                      pixelated=True,
                      hillshade_style=hillshade_style)
#layer = lbm.MapLayer(wcs_data, style)
layer = lbm.MapLayer(gdal_data, style)
layers.append(layer)

## Country borders
data = lbm.BuiltinData("countries")
country_style = lbm.LineStyle(line_color="r", line_width=2, line_pattern='--')
layer = lbm.MapLayer(data, country_style)
layers.append(layer)

## Coastlines
coastline_style = lbm.LineStyle(line_color="r", line_width=2)
data = lbm.BuiltinData("coastlines")
layer = lbm.MapLayer(data, coastline_style)
layers.append(layer)

map = lbm.LayeredBasemap(layers, title, projection, region=region)
map.plot()
#legend_style = lbm.LegendStyle(location=0)
legend_style = None
title_style = lbm.DefaultTitleTextStyle
title_style.weight = "bold"
#scalebar_style = lbm.ScalebarStyle((4.,49.25), 100, bar_style="fancy")
scalebar_style = None
border_style = lbm.MapBorderStyle(fill_color='powderblue')
#graticule_style = lbm.GraticuleStyle(annot_axes="")
graticule_style = None
map = lbm.LayeredBasemap(layers,
                         title,
                         projection,
                         region=region,
                         resolution=resolution,
                         title_style=title_style,
                         graticule_interval=graticule_interval,
                         graticule_style=graticule_style,
                         legend_style=legend_style,
                         scalebar_style=scalebar_style,
                         border_style=border_style,
                         dpi=200)

fig_filename = "ROB_catalog%s.PNG" % file_name_ext
fig_filespec = os.path.join(out_folder, fig_filename)
#fig_filespec = None
if fig_filespec:
    dpi = 600
else:
    dpi = None

map.plot(fig_filespec=fig_filespec, dpi=dpi)
#src_label_name = rob_source_models_dict[sm_name].column_map['id']
src_label_name = None
data = lbm.GisData(gis_filespec, src_label_name)
#label_style = lbm.TextStyle(color='indigo', font_weight="bold", horizontal_alignment="center", vertical_alignment="center")
front_style = lbm.FrontStyle('asterisk', interval=15, num_sides=1, line_color=None, line_width=None, angle=180)
line_style = lbm.LineStyle(line_width=3, line_color="red", label_style=None, front_style=front_style)
style = lbm.CompositeStyle(line_style=line_style)
layer = lbm.MapLayer(data, style, legend_label={"lines": "Fault traces"})
layers.append(layer)

## Background source
sm_name = "RVRS_area"
gis_filespec = rob_source_models_dict[sm_name].gis_filespec
#src_label_name = rob_source_models_dict[sm_name].column_map['id']
src_label_name = None
data = lbm.GisData(gis_filespec, src_label_name)
label_style = lbm.TextStyle(color='indigo', font_weight="bold", horizontal_alignment="center", vertical_alignment="center")
polygon_style = lbm.PolygonStyle(line_width=2, line_color="indigo", fill_color="None", label_style=label_style)
style = lbm.CompositeStyle(polygon_style=polygon_style)
layer = lbm.MapLayer(data, style, legend_label={"polygons": "Background zone"})
layers.append(layer)

region = (4, 7.5, 50.25, 52)
projection = "merc"
legend_style = lbm.LegendStyle(location=1)
#legend_style = None
title = "RVG fault model"
graticule_style = lbm.GraticuleStyle(annot_axes="SE")
map = lbm.LayeredBasemap(layers, title, projection, region=region, graticule_interval=(1,0.5), graticule_style=graticule_style, legend_style=legend_style)
map.plot(fig_filespec=fig_filespec)
colorbar_style = lbm.ColorbarStyle(title="Rake",
                                   format="%s",
                                   ticks=None,
                                   spacing="proportional")
thematic_color = lbm.ThematicStyleRanges(
    [-180, -135, -45, 45, 135, 180],
    ['yellow', "green", "yellow", "red", "yellow"],
    value_key="rake",
    colorbar_style=colorbar_style)
#thematic_color = lbm.ThematicStyleGradient([-180, -90, 0, 90, 180], ['yellow', "green", "yellow", "red", "yellow"], labels=["RL", "Nf", "LL", "Tf", "RL"], value_key="rake", colorbar_style=colorbar_style)
thematic_legend_style = None

focmec_style = lbm.FocmecStyle(size=thematic_size,
                               fill_color=thematic_color,
                               thematic_legend_style=thematic_legend_style)
layer = lbm.MapLayer(focmec_data, focmec_style)
layers.append(layer)

legend_style = lbm.LegendStyle(location=1)
title_style = lbm.DefaultTitleTextStyle
title_style.weight = "bold"
map = lbm.LayeredBasemap(layers,
                         title,
                         projection,
                         region=region,
                         title_style=title_style,
                         graticule_interval=graticule_interval,
                         resolution=resolution,
                         legend_style=legend_style)
map.plot(fig_filespec=fig_filespec)
示例#5
0
    line_color=lbm.ThematicStyleRanges([0., 5., 15., 20.], ['r', 'g', 'b'],
                                       value_key='depths'),
    fill_color='r',
    #	fill_color=None,
)
layers.append(lbm.MapLayer(multipoint_data, multipoint_style))

image_data = lbm.ImageData("C:\\Temp\\banerNL.gif", 1, 49)
image_style = lbm.ImageStyle(horizontal_alignment='left',
                             vertical_alignment='bottom')
layer = lbm.MapLayer(image_data, image_style)
#layers.append(layer)

map = lbm.LayeredBasemap(layers,
                         title,
                         projection,
                         region=region,
                         resolution=resolution,
                         graticule_interval=graticule_interval)

#lons = [map.llcrnrlon, map.urcrnrlon]
#lats = [map.llcrnrlat, map.urcrnrlat]
#print(zip(lons, lats))
#x, y = map.lonlat_to_map_coordinates(lons, lats)
#print(zip(x, y))

#map.plot()

map.export_geotiff(out_filespec="C:\\Temp\\matplotlib.tif",
                   dpi=200,
                   verbose=True)