I'm using Mapnik v2.2.0 from Python 2.7 in an Ubuntu 16.04 environment. The application generates maps with a set of MarkerSymbolizers at various coordinates. In one map, when the MarkerSymbolizers are set to 25x25 pixels, one of the markers does not appear. If the marker size is set to 15x15, all of the markers appear.
The markers are loaded from a csv file:
layer = mapnik.Layer('GPS_tracking_points')
layer.datasource = mapnik.CSV(file=leak_file_name, layer_by_index=0)
The styling is below:
point_style = mapnik.Style()
point_rule = mapnik.Rule()
point_filter = mapnik.Filter ("[val] > 10")
point_rule.filter = point_filter
point_point_symbolizer = mapnik.MarkersSymbolizer()
point_point_symbolizer.width = mapnik.Expression ('25')
point_point_symbolizer.height = mapnik.Expression ('25')
point_point_symbolizer.fill = mapnik.Color ('#ff0000')
point_point_symbolizer.allow_overlap = True
point_point_symbolizer.opacity = 0.5 # semi-transparent
point_rule.symbols.append(point_point_symbolizer)
point_style.rules.append(point_rule)
map_canvas.append_style('high', point_style)
Screenshots are below.
Any help is appreciated.
Thanks.
The problem appears to be related to the way Mapnik 2.2 handles styling in code vs xml. I moved the styling specification to an xml file and everything works as expected.
The answer was found here: https://github.com/mapnik/python-mapnik/issues/117
Related
I have some discrepancies in terms of brightness, saturation and hue when using a jpg picture in Manim.
I have a picture which color profile/space is Adobe RGB. I create it, edit it and save it that way. All of my apps previewing the picture are more, or less consistent with the original (enough to be acceptable). Including a movie export test from After effects. Even the image previewer of VS Code shows the image correctly. But when I render it with Manim, it's no good. Way too bright, oversaturated with a slight shift in hue and as if it was downgraded in terms of quality (some subtle but weird color artifacts are showing). You can tell something is off.
Granted, the picture I try to use is an abstract background with subtle gradients of color and light but still. The overall difference and loss in quality are sufficiently there not to be acceptable.
I know that managing color spaces and profiles is a bit tricky and is an art in and on itself but the problem here is that the image is consistent everywhere so far but in Manim's rendered MP4 file.
The only thing I've seen in the doc related to color spaces is this parameter "image_mode". I tried to set it both to RGB and RGBA (only two options available) in the Manim script but it doesn't change anything.
I suspect it's a feature that is more related to the renderer (Cairo) or the MP4 export parameters than Manim itself or maybe it downgrades jpg to gif/png before it renders the picture in Mp4 ? I don't know and I don't know what to do with that anyway since I don't know how to parameter any of this within Manim itself. I can't see any parameters that allow to edit any of this in the doc.
Maybe a plugin could add some functionalities or something ?
Any help would be appreciated.
PS: the picture is 4k and I render it in 4k in Manim, so it should be a pixel to pixel match.
Here is my Manim script:
from manim import *
class Graph(Scene):
def construct(self):
bg = ImageMobject("media/background/13.jpg")
self.add(bg)
self.wait()
And here are the relevant parts of my manim.cfg
[CLI]
write_to_movie = True
format = mp4
save_last_frame = False
write_all = False
save_pngs = False
save_as_gif = False
preview = False
background_color = #212021
background_opacity = 1
renderer = cairo
use_webgl_renderer = False
webgl_renderer_path =
use_opengl_renderer = False
enable_gui = False
gui_location = 0,0
fullscreen = False
window_size = default
window_monitor = 0
force_window = False
use_projection_fill_shaders = False
use_projection_stroke_shaders = False
movie_file_extension = .mp4
frame_rate = 60
frame_size = 3664,1980
pixel_height = 1980
pixel_width = 3664
max_files_cached = 100
flush_cache = True
disable_caching = True
disable_caching_warning = False
enable_wireframe = False
dry_run = False
tex_template =
plugins =
TL;DR: Some random pointers, but no answer to the question.
I have no clue about manim, so I just went searching for "JPEG" in its source code. That brought me to https://github.com/3b1b/manim/blob/3c7a38660af41478e1561073a5319b23fb6b7787/docs/source/documentation/custom_config.rst#L59 which says
The directory for storing raster images to be used in the code (including .jpg, .jpeg, .png and .gif), which will be read by ImageMobject.
Okay, what's ImageMobject? Another search found the place where it loads images and apparently this just uses the Python library PIL to call PIL.Image.open: https://github.com/3b1b/manim/blob/669182944da040c227ccfd018250ee2bbc49649d/manimlib/mobject/types/image_mobject.py#L31
Okay, so does this support color profiles? I don't know. What does this question even mean? You are loading some color image that contains a color profile and it ends up being part of a movie... Should the movie now use that color profile?
Another random pointer that I found is PIL/Pillow decode icc profile information but that didn't really help. All I can say is: The manim code that I found doesn't do anything fancy with color profiles.
Is it possible to adjust the centre coordinate of a bokeh google map plot and refresh the plot? I'm intending to centre the selected point according to user input in a bokeh TextInput field.
A piece of example code for displaying the map is shown below.
source = ColumnDataSource(data=dict(<...>))
origin = (<...>, <...>)
options = GMapOptions(lat=origin[0], lng=origin[1], map_type="roadmap", zoom=11)
tools = "crosshair,pan,wheel_zoom,reset,save"
location_map = gmap(environ.get('API_KEY'), options, title="Station locations", tools=tools, active_scroll="wheel_zoom")
r = location_map.circle(x="lng", y="lat", size=15, fill_color='color', fill_alpha=0.8, source=source)
Okay this is kind of old, but I think I found the answer. I know that GMapPlot used in Bokeh has an update function that allows you to update existing parameters. I'm pretty sure that gmap is very similar to GMapPlot so...
options = GMapOptions(lat=origin[0], lng=origin[1], map_type="roadmap", zoom=11)
location_map = gmap(environ.get('API_KEY'), map_options=options, title="Station locations", tools=tools, active_scroll="wheel_zoom")
updated_options = GMapOptions(lat=new_lat, lng=new_lng, zoom=new_zoom)
location_map.update(map_options=updated_options)
Sorry if the formatting is off. It's my first post.
I am able to open a 3DS file in MeshLab and when I export to Collada DAE format the textures are visible but they are not being projected onto the mesh in the same way as the preview in MeshLab. For example, the front/back faces of a cube would have the proper texture (suppose it's a polka dot) but the top and bottom have a striped look. How can I apply a single texture and have it appear as intended on all faces, like the imported model before I convert it?
This problem is a result of the end software being used to view the DAE file. It's not a problem with MeshLab.
For example, if loading the file into Away3D be sure to handle the texture materials using the TextureMaterial class instead of the simpler SinglePassMaterialBase such as what you might find in their example code. Here is what I use now, and it displays texture properly:
var material:TextureMaterial = cast(asset, TextureMaterial);
material.ambientColor = 0xffffff;
material.lightPicker = _lightPicker;
material.shadowMethod = new FilteredShadowMapMethod(_light);
material.lightPicker = _lightPicker;
material.gloss = 30;
material.specular = 1;
material.ambient = 1;
material.repeat = true;
I've noticed that the OM Script gets commented when I add a bitmap in either the Icon/Diagram View.
I'm using OpenModelica 1.9.1+dev (r18667) (RML version)
Code for reference
model Test
annotation(Diagram(coordinateSystem(extent = {{-100,-100},{100,100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2,2}), graphics = {Bitmap(origin = {0.12,-0.47}, extent = {{-99.77,99.65000000000001},{99.77,-99.65000000000001}}, fileName = "modelica://Test/C:/Users/MSK/Desktop/Capture.PNG")}));
end Test;
This may be a bug. Hence I've reported it
OpenModelica bug reports should be reported at: https://trac.openmodelica.org/OpenModelica/newticket
And yes, it is a bug so it does not really belong on stackoverflow.
I'm working at galery on o3d(plagin version) and I need make photos transparent. Photos are on hud. Here is some code:
g_canvasInfoPict = o3djs.canvas.create(g_pack, g_hudRoot, g_hudViewInfo);
alphaParam = g_canvasInfoPict.transparentState_.getStateParam("o3d.AlphaReference");
alphaParam.value = 0.5;
alphaParam = g_canvasInfoPict.transparentState_.getStateParam("o3d.BlendAlphaEquation");
alphaParam.value = g_o3d.State.BLEND_SUBTRACT;
alphaParam = g_canvasInfoPict.transparentState_.getStateParam("o3d.SourceBlendFunction");
alphaParam.value = g_o3d.State.BLENDFUNC_ONE;
paramOne = g_canvasInfoPict.transparentState_.getStateParam("o3d.DestinationBlendFunction");
paramOne.value = g_o3d.State.BLENDFUNC_DESTINATION_ALPHA;//or BLENDFUNC_SOURCE_ALPHA or BLENDFUNC_SOURCE_ALPHA_SATUTRATE or BLENDFUNC_ONE or BLENDFUNC_ZERO
g_fullPictCanvas = g_canvasInfoPict.createXYQuad(paddingX, paddingY, -14, g_fullPictTexture.width, g_fullPictTexture.height, true);
g_fullPictCanvas.canvas.drawBitmap(g_fullPictTexture, 0, g_fullPictTexture.height);
g_fullPictCanvas.updateTexture();
But it doesn't work. When setting paramOne.value = BLENDFUNC_ZERO photo displays (non-transparent)
paramOne.value = BLENDFUNC_ONE photo isn't displayed (full transparent)
So how to achive intermediate result?
Given that the O3D plug-in is deprecated in favor of the WebGL-based O3D, is it an option for you to migrate to the latter?
If so, you can inquire in the discussion group about the transparency issue (if it still exists under O3D-WebGL). The developers are very responsive.