Geopackage: convert BLOB to coordinates - sqlite

I'm working with SQLite-Mananger Plugin for FireFox to edit my local geopackage database.
The geometry is stored as BLOB in various tables.
Now I'd like to encode the not readable BLOB format into human readable coordinates.
I already tried it that way:
Select STAsText(geometry) as geometry from table;
With the following error:
no such function: STAsText
I guess because it is a local database and the STAsText-function is for SQL-Sever.
I also tried it with:
SELECT quote(geometry) FROM table
But with this I also get no coordinates.

just use GDAL OGR2OGR "ogr2ogr -f "GeoJSON" path/filename.geojson path/filename.gpkg"
Or use QGIS Desktop. GeoPackage uses a derivation of WKB -Well Known Binary for it's Vector Features BLOB. Conversion to GeoJSON is very straight forward. You can also use GeoPackage-JS to do the conversion.
Click Open Geopackage and it will allow you to download as GeoJSON http://ngageoint.github.io/geopackage-js/

Related

Ogr2Ogr conversion to SQLIte: geometry format?

I use ogr2ogr to convert DXF-files. The conversion to KML and geojson works very well.
For another purpose I need to convert the DXF to SQLite. It works, but I don't know how to use or read the geometry. There's a table "Entities" with a column "GEOMETRY" in somewhat BLOB format.
Does anybody know how to convert this GEOMETRY to WKT, JSON, x/y or something else?
I tried Spatialite (AsText, AsWKT, AsKML) without success.
Thanks!
EDIT/CLOSE:
After many hours I found the cli-parameter -lco to change the geometry format to WKT.
The doc (https://gdal.org/drivers/vector/sqlite.html#layer-creation-options) lists many parameters but has no examples how to use them.
So my working command line is:
ogr2ogr.exe -f SQLite -lco FORMAT=WKT target_wkt.db source.dxf

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.

How to import a gpx file in an input, transform it in geojson and display it on my mapbox

I would like that when I add a gpx file in my input, it is taken into account and displayed on the map.
Apparently I saw that it was necessary to convert the gpx file in format to geojson then to send this variable in the code data in map.addsource. But I can't get the gpx and convert it automatically to geojson for the moment.
Can you help me ?
The map control only understands GeoJSON, vector tiles, and raster tiles. So in order to display GPX data, you would need to convert it to one of these types. GeoJSON is likely the best option here unless you have a massive GPX file (hundreds of MB) at which point vector tiles would be the right choice. To convert GPX to GeoJSON in a web app, use this library: https://github.com/mapbox/togeojson

Changing encoding of layers in Leaflet

I'm using Leaflet in R to make an interactive map.
Data I'm using was created using QGIS with Windows-1250 encoding (it's a non-English language). The layers were then exported as geoJSON which only allows UTF-8 encoding and when displaying the features on the map some characters are, of course, displayed wrong.
Is there a way of displaying the encoding properly? Trying to manually change the data results in:
Error: unexpected symbol in x' (x is the wrongly encoded data point I tried to rewrite).
You're not specifying the vector format of the data before being exported - this is more important than the tool used to create that data.
Assuming that the data is in shapefiles, you can use the approach from the question at https://gis.stackexchange.com/q/44057 , and rely on ogr2ogr to both convert to GeoJSON and handle character encoding.

Generate MapTiles from BSB/KAP files Using GDAL2Tiles

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.

Resources