Openstreetmaps: Make my scale have 1cm in the paper - leaflet

I got a complain from a client that said that the scale on the paper had 1.2 cm instead of 1 cm. I'm trying to fix this but I don't have much experience with openstreetmaps nor leaflet to know where do I need to change the code to make my scale have 1 cm all the time.
Can someone point me to the right direction? Thanks in advance

Instead of the standard Leaflet Scale Control, you should write your own Control (or any other widget). The standard one does not have a fixed length: it adjusts it so that it can represent a "round" distance (like "1km", "50km", etc.). But it sounds like you want the reverse: have a fixed length, representing whatever distance.
You should check the pixel to length (on paper) ratio of your browser and printer. You should be able to adjust zoom / scale.

Related

AnyLogic - Can density map be more accurate?

Can you change the size of pixels in Density Map?
I suspect that the size of density map pixels is based on agent/pedestrian size. Can it be modified, so that pixels are smaller and leave more precise trace?
Currently, my density map leaves huge pixels that are very difficult to use as reliable information.
EDIT: Screenshot below,
Thanks,
Peter
I am pretty sure it's not possible, the density map has a resolution of 1 meter (whatever the equivalent to 1 meter is by your scale object) and there's no way to change it (as far as I know)
But, what you have to make up for this, is the canvas object that you can find in the presentation palette. With the canvas object you can define your own resolution but you also have to code your own density map using your own personalized rules. Check the help documentation to understand how to use this and check the wondering elephants model to understand how to make changes dynamically.

Scale graphics with pygame_util

I am building a model with pymunk and I need to use real dimensions (physical size of model is approximately 1 meter). Is there a way to scale the graphics in pygame_util so that 1 meter corresponds to 800 pixels?
Pymunk itself is unitless, as described here: http://www.pymunk.org/en/latest/overview.html#mass-weight-and-units
Pymunk 6.1 (and later)
With Pymunk 6.1 its now possible to set a Transform on the SpaceDebugDrawOptions object (or one one of the library-specific implementations like pygame_utils.DebugDraw) as documented here http://www.pymunk.org/en/latest/pymunk.html#pymunk.SpaceDebugDrawOptions.transform
With this new feature it should be possible to set a scaling Transform to achieve what you are asking about.
Pymunk 6.0 (and earlier)
When used with pygame_util the distances will be measured in pixels, e.g. a 10x20 box shape (create_box(size=(10,20))) will be drawn as a 10x20 pixels rectangle. This means that the easiest way to achive what you ask about is to just define that the Pymunk length unit is 0.125cm, and therefore the box shape above 1.25cm x 2.5cm.
An alternative would be to scale the surface once complete. So instead of using the screen surface in pymunk.pygame_util.DrawOptions() you use a custom surface that you scale when the space has been drawn and then blit the result to the screen. I dont think this option is a good as the first option since there might be scaling artifacts, but depending on your exact use case maybe it works.

Make symbol layer icon-size zoom invariant

I am attempting to place a hexagon (centred over co-ordinates) which I can interact with, hover/onclick. The method I am using is to LoadImage(..._Hexagon.png) and then addLayer. Eventually the idea is to have many hexagons over specific areas.
I have obtained the desired interaction with the shape, but I would like this layer to be invariant under zoom (ie I have the hexagons cover an area of x square km at all times regardless of zoom). Is there an efficient way to do this? Will another method be better? etc
Thank you in advance for any and all advice!
If you really want to scale an icon such that it gets bigger as you zoom in, you can use an exponential scale:
"icon-scale": ["*", ["interpolate", ["exponential", 2], ["zoom"]], SCALE]
where SCALE is some constant you pick.
It probably makes more sense to actually generate hexagonal polygon data (eg, using Turf), and displaying that though.

Image processing/restoration in Matlab

I have several images that i would like to correct from artifacts. They show different animals but they appear to look like they were folded (look at the image attached). The folds are straight and they go through the wings as well, they are just hard to see but they are there. I would like to remove the folds but at the same time preserve the information from the picture (structure and color of the wings).
I am using MATLAB right now and i have tried several methods but nothing seems to work.
Initially i tried to see if i can see anything by using an FFT but i do not see a structure in the spectrum that i can remove. I tried to use several edge detection methods (like Sobel, etc) but the problem is that the edge detection always finds the edges of the wings (because they are stronger)
rather than the straight lines. I was wondering if anyone has any ideas about how to proceed with this problem? I am not attaching any code because none of the methods i have tried (and described) are working.
Thank you for the help in advance.
I'll leave this bit here for anyone that knows how to erase those lines without affecting the quality of the image:
a = imread('https://i.stack.imgur.com/WpFAA.jpg');
b = abs(diff(a,1,2));
b = max(b,[],3);
c = imerode(b,strel('rectangle',[200,1]));
I think you should use a 2-dimensional Fast Fourier Transform
It might be easier to first use GIMP / Photoshop if a filter can resolve it.
I'm guessing the CC sensor got broken (it looks to good for old scanner problems). Maybe an electric distortion while it was reading the camera sensor. Such signals in theory have a repeating nature.
I dont think this was caused by a wrong colordepth/colorspace translation
If you like to code, then you might also write a custom pixel based filter in which you take x vertical pixels (say 20 or so) compare them to the next vertical row of 20 pixels. Compare against HSL (L lightnes), not RGB.
From all pixels calculate brightness changes this way.
Then per pixel check H (heu) is within range of nearby pixels take slope average of their brightness(ea take 30 pixels horizontal, calculate average brightnes of first 10 and last 10 pixels apply that brightness to center pixel 15,... //30, 15, 10 try to find what works well
Since you have whole strokes that apear brighter/darker such filter would smooth that effect out, the difficulty is to remain other patterns (the wings are less distorted), knowing what color space the sensor had might allow for a better decision as HSL, maybe HSV or so..

NetLogo Dimensions In Space

1.How does the coordinate system in NetLogo shape in terms of "cms" as horizontal coordinate(cm) and vertical coordinate(cm)?(The settings tab sure does give in pixels but I unfortunately don't know the conversion between pixels and cms)
2.How does turtle size correlate with or is specified in pixels?
UPDATE.
Is there any possible way given my screen resolution I can accomplish the above conversion?
I found some links http://www.unitconversion.org/typography/pixels-x-to-centimeters-conversion.html claiming to do the above I don't know regarding their crediblity
1.How does the coordinate system in Netlogo shape in terms of "cms" as horizontal coordinate(cm) and vertical coordinate(cm)?(The settings tab sure does give in pixels but I unfortunately don't know the conversion between pixels and cms)
It doesn't. There is no general conversion between pixels and centimeters, nor should there be. The physical size of a pixel depends on your screen size and resolution. For the purpose of a model, you can always decide that, e.g., 10 pixels represent 1cm, but this would have no correlation to actual physical size on screen.
2.How does turtle size correlate with or is specified in pixels?
Ah! This one actually has an answer: a turtle of size 1.0 is the same size as a patch, and patch-size gives you the size of a patch in pixels. The size of a turtle in pixels is thus size * patch-size. Note, however, that this is the size of the side of the square occupied by the turtle; not the actual area of the shape displayed on the screen.
Is there any possible way given my screen resolution I can accomplish the above conversion?
This depends not only on the resolution of the monitor, but the monitor itself. For instance, if your monitor is 1440x900 and you project up on a screen, or plug into an external monitor that scales the output, obviously the pixels-per-cm is going change dramatically, even though the resolution stays the same. Even within the same monitor, this can change. For instance, many modern laptops (notably macbook pros) have so called hi-dpi screens with huge resolutions. Applications on the screens can be run in scaled or non-scaled formats, which completely changes the pixels-per-cm (e.g. NetLogo 5.0.5 ran in scaled-mode on OS X, but 5.1 runs in non-scaled-mode; you'll notice that the text on retina screens looks considerably sharper and less pixelated). Even just in netlogo, you can zoom in and out, which changes the scale of all the elements (see the zoom menu).
So, the only way to determine the pixels-per-cm is for a specific application on a specific monitor running under a specific resolution with specific settings. In that case, your best bet for measuring the size of patches and turtles is probably a ruler. You can probably find some applications that give you a "screen ruler", but the only trustworthy ones I'm aware give the answer in pixels, and I probably wouldn't trust anything that claims to give cm.
I think you're having trouble getting the answer you want here because, in some sense, the question doesn't really make sense. The measurement of patches in cm can always be changed at will and will always change depending on environment. So perhaps the best answer to your first question is "whatever you want it to be".