Generate MapTiles from BSB/KAP files Using GDAL2Tiles - dictionary

As an example I have a BSB file from NOAA which is a navigational map. The map has a SRS of WGS84 and a Mercator projection.
I initially translate the file from BSB format to GTiff format using the following command:
gdal_translate -of GTiff 18554_1.kap noaa.tif
I can view this GTiff file using Paint Shop Pro quite fine. I then translate the file from GTiff format to VRT format using the following command:
gdal_translate -of vrt –expand rgba noaa.tif noaa.vrt
I then try to generate a tile matrix set using the following command:
gdal2tiles.py noaa.vrt tiles_folder
Where the map tiles are located in tiles_folder. If I try to open the openmaps.html or google.html, the map zoom in and out looks good. However, on tiles generator like MBTiles, I see tiles swap. See the image below. I am pulling my hair off to get the tiles to line up. I am guessing it is projection error. I am not understanding those projection types. It would great someone can explain it while finding the error. I am planning to use on a tiling maps/charts app like this. By the way, on GDAL how do I specify the BSB (reference) file that is associated with KAP (data) file? I have seen cases where only one BSB file referred by multiple KAP files.
Gdal2tiles swapped tiles

There is no problem with the map projection, but the tiles are cut according the TMS notation (with tile [0,0] in the bottom left) in GDAL2Tiles.
Some tools expect the Google XYZ notation (with tile [0,0] in the upper left corner).
The tiles are otherwise equal, they have just flipped Y coordinate in the file name.
Have a look at this:
I prepared a website which shows visually the difference and also explains the problem. Have a look at:
http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
There is also a source code for how the tiles and all coordinates are calculated. It is part of the GDAL2Tiles which you mentioned above - which is a code I created some years back.
Your second question is was about MBTiles. The mbutil utility has a parameter "--scheme tms" which allows to create the MBTiles file from tiles rendered with gdal2tiles.py.
GDAL reads just the KAP file, where each represents a map in the sheet (in case there are insets).
BTW Do you know that there is http://www.maptiler.com/ which solves the problems mentioned above directly? You can just drag&drop into the GUI or pass on the command line the KAP file as it is and choose whether you want tiles in directory or MBTiles and it will directly render the output. The tiles are directly optimised as well, there is support for rendering multiple input files into a single layer and rendering is of magnitude faster then with GDAL2Tiles.

Related

How to read the map output file generated by a project using Cartographer without ROS

Currently I can successfully generate the map output file but I have no idea how to display it in practice. Basically, it should be a 2D SLAM map.
The project I'm using is available at the following link on Github. This project basically uses Google Cartographer 2D SLAM without ROS.
Compiling the project I get an output file called "map_output" but it seems to be completely raw: it's not even binary. How can I convert or read it in a viewable format?
Inside the main file, specifically inside the main function, it can be seen how data consisting of inertial measurements (IMU) is taken as input and processed to provide an output map.
Update: map_output file is available here. (IMU data file is available here.) I'm pretty sure both can be read and/or represented in the same way.

Power BI change the Map Shape visualisation TOPOJSON source file at run time

Is it possible to change the source TOPOJSON file for the Map Shape visualisation. Theory is for the user to select an option in a slicer which would load a different source file for the map shape.
PBIX is published to a workspace.
Any ideas or suggestions on how to go about it.
Thanks

Why does R raster::writeRaster() generate a pic which can't be shown in Win10?

I read my hyperspectral (.raw) file and combine three bands to "gai_out_r" Then I output as following:
writeRaster(gai_out_r,filepath,format="GTiff")
finally I got gai_out_r.tif
But, why Win10 can't display this small tif as the pic that I output the same way from envi--save image as--tif
Two tiffs are displayed by Win10 as following:
Default windows image viewing applications doesn't support Hyperspectral Images-since you are just reading and combining 3 bands from your .raw file, the resulting image will be a hyperspectral image.You need to have separate dedicated softwares to view hypercubes or can view it using spectral-python also.
In sPy, using envi.save_image , will save it as a ENVI type file only. To save it as an rgb image file(readable in windows OS) we need to use other methods.
You are using writeRaster to write to a GTiff (GeoTiff) format file. To write to a standard tif file you can use the tiff method. With writeRaster you could also write to a PNG instead
writeRaster(gai_out_r, "gai.png")
Cause of the issue:
I had a similar issue and recognised that the exported .tif files had a different bit depth than .tif images I could open. The images could not be displayed using common applications, although they were not broken and I could open them in R or QGIS. Hence, the values were coded in a way Windows would not expect.
When you type ?writeRaster() you will find that there are various options when it comes to saving a .tif (or other format) using the raster::writeRaster() function. Click on the links therein to get to the dataType {raster} help site and you'll find there are various integer types to choose from.
Solution (write a Windows-readable GeoTIFF):
I set the following options to make the resulting .tif file readable (note the datatype option):
writeRaster(raster, filename = "/path/to/your/output.tif",
format = "GTiff", datatype = "INT1U")
Note:
I realised your post is from 2 and a half years ago... Anyways, may this answer help others who encounter this problem.

gnuplot - How can I save a graphics file of a plot that is the same as I designed it in xterminal?

I have been making plots for some time now, and they are precisely the way I like them, on screen. The data is coming in from sensors related to solar power collection and storage.
Plotted on screen they look great so I do a screen region capture to save them.
So now I would like to automate the saving process.
Here is what I have done so far:
I set up a cron job so they would be run right at midnight, capturing the whole day and saving it as a .png file
Then it moves the "today.dat" data file to the archive named by date.
This part is all working as designed.
EXCEPT, by using .PNG the images do not look the same.
I really thought png would be the best option, but it turns out that the font used for the X-axis (HH:MM ticks) is too thick and they run together. It looks like a crayon-drawn version of my plot designs.
Can someone please give me some guidance on how to best programatically generate the plots for saving so they look like the way I designed them?
As pointed out in the comments above, the best way is probably to use a different terminal for output to an image file, and simply ignore the fact that the generated images are not identical to what you see on your screen when using the x11 terminal. However, if you really need an exact copy, there are (at least) two options:
You could automate the process of taking a screenshot. You can even do this from within gnuplot, where it might come handy that the GPVAL_TERM_WINDOWID variable contains the X Windows ID for the current plot window. You can use that to make a screenshot of the window after you made the plot:
system(sprintf("xwd -id 0x%x | convert xwd:- screenshot.png", GPVAL_TERM_WINDOWID))
Here I included a call to convert to convert the xwd file format to png.
Another option is to use the xlib terminal, which saves the sequence of commands that the gnuplot_x11 helper application turns into the window you see on the screen. For example,
set term push; set term xlib; set output "file.xlib"; replot; set output; set term pop
will create the file file.xlib that has all the information of the last plot. To later view this plot, use
gnuplot_x11 -noevents -persist < file.xlib
where you might have to specify the path to gnuplot_x11.
Similar as #user8153 suggested for x11, you can use import, which is as convert an imagemagick tool
system("import -window ".GPVAL_TERM_WINDOWID." screenshot.png")
Convenient is also a shortcut to copy the image into clipboard and paste it with Ctrl+v elsewhere:
bind Ctrl-c 'system("import -window ".GPVAL_TERM_WINDOWID." png:- | xclip -sel clip -t image/png")'
See also Show graph on display and save it to file simultaneously in gnuplot.

Extracting path data from an SVG map to use in RaphaelJs

I'm trying to build an an interactive map using RaphaelJS (e.g. http://raphaeljs.com/australia.html). Please check the source. It requires map path data to input. There is no clear explanation anywhere about how to obtain this information, other than the fact that illustrator or inkscape are capable of doing it.
I'm looking to obtain "States" path data from this India map: http://en.wikipedia.org/wiki/File:India-locator-map-blank.svg
well, this one is easy. SVG is just a simple XML file. So you don't have to "extract" anything via Illustrator.
Just open the SVG in any text editor and it's all there! (the path data string you can use with RaphaelJS path-function is held in the d-attribute of the path nodes).
Watch our for copyright issues when using SVG files of others ;)
Skunks
You could also use a converter like Ready.Set.Raphael to extract the paths for you and create the javascript output. It's a real time saver!
For older SVG files the path data will need to be optimized for RaphaelJS. Open the file in Inkspace and save as Optimized AVG. If you have an AVG file that opens as a blank image in Adobe Illustrator, edit the file with a text editor and set the first two values of the viewBox to 0,0. Both steps may be required when working with map AVG files from Wikipedia.

Resources