Convert/Warp raster imagedata from EPSG31466 to 4326 for OpenStreepMap overlay - openstreetmap

I have a raster image in Gauss Krüger 2 projection that I need to use as overlay in OpenStreetMap and learned so far that I need to warp/translate/convert the image using tools like GDAL.
I tried gdalwarp with the following results:
$ gdalwarp -s_srs 'EPSG:31466' -t_srs 'EPSG:4326' kg2-map.png osm-map.tiff
ERROR 1: Unable to compute a transformation between pixel/line
and georeferenced coordinates for /kg2-map.png
There is no affine transformation and no GCPs.
What do I need to do in order do get this task done?

You need to georeference the PNG source file, so that each pixel has a coordinate and resolution. If you know the coordinate of the top left corner and the resolution, make a 6-line world file named kg2-map.pngw or kg2-map.pgw.

Related

Why is Tippecanoe conversion of geojson file to pbf vector tiles resulting in incorrect lat/long placement?

I'm trying to generate pbf vector tiles from json data using tippecanoe. Ultimately will be served up for use in OpenLayers but had no success there so tried testing the tiles in QGIS. When I view any of them (in QGIS) instead of being in the longitude range of -180 to +180 they are in the ~2000 to ~4000 range.
I have a simple json file consisting of a rectangle surrounding Europe using EPSG:4326.
I use tippecanoe to generate the pbf tiles.
jim.json consists of:
{"features":[{"geometry":{"coordinates":[[0,0],[0,80],[80,80],[80,0],[0,0]],"type":"LineString"},"properties":{"level-index":1,"level-value":956.0,"stroke":"#a52a2a","stroke-width":1,"title":"956.00 "},"type":"Feature"}],"type":"FeatureCollection","crs":{"type": "name","properties": {"name": "urn:ogc:def:crs:OGC:1.3:CRS84"}}}
Then I run this command:
tippecanoe --no-feature-limit --no-tile-size-limit --no-tile-compression -s EPSG:4326 --output-to-directory TilesDir --force jim.json
Then if I try to see if the tiles are correct, I take the largest one (0/0/0.pbf) into QGIS and the rectangle gets plotted outside of the earth out at 2000degE instead of in the expected area near Europe.
It turns out that QGIS is not the appropriate tool to test the pbf. After correcting some other issues, I was able to display the pbf in OpenLayers. I assume tippecanoe generates the pbf with some internal coordinate system (4096x4096 pixels?) not the EPSG:4326 that I was expecting.

Vector layers with mapboxgl with no coordinates

Is there a way to draw a vector layer with CorelDraw for example and place it on napboxgl and use it as geojson layers?
For example https://seatgeek.com/colorado-rapids-at-seattle-sounders-fc-tickets/mls/2017-10-22-1-pm/3700786
Are they using geojson or etc.? Or just some sort of vector format?
I can't use geojson as it is hard to draw with QGIS any straight lines or symmetrical objects. I just want to draw a lot of vector objects and use them as layers with mapboxGL(use mapbox as render method and interact with layers as with geojson)
Any suggestions how to do it? Or is there a way to draw with Corel and then place it on map with QGIS?
Thanks
UPD:
Now I am using Corel -> dxf export and then import it to QGIS, then save it as geojson. But have some glitches with displaying that geojson geometry in mapbox, so I have to draw another in QGIS over the imported(dxf) one.
Here is an example of the bug, should be just a green polygon like the gray one
UPDATE: my fault, I was using lines instead of polygons.
I think you can achieve this as follows:
Convert the Corel output to SVG
Create an HTML element containing the SVG (not necessarily added to DOM)
On your Mapbox map, add a Canvas source containing the canvas: see https://www.mapbox.com/mapbox-gl-js/api/#canvassource
Obviously you will need to determine the lat/lon of the corners of your image somehow.

tilemill creates jagged edges for worldmap

Trying to create a custom world map texture with tilemill to load into leafletjs. I have downloaded a free .tiff file from natural earth data and loaded it into tilemill.
When i want to export however, i notice alot of jagged edges mainly around greenland/canada on the lowest zoom level.
a few zoom levels down and it seems ok again. After exporting the tiles to png's the jagged edges stay. How can i improve the quality of these images?
How can i improve the quality of these images?
By using more detailed input data.
By the looks of it, you are projecting a raster image in EPSG:4326 projection into the EPSG:3857 "web mercator" projection. In the original data, each pixel spans the same amount of longitude and latitude degrees. In a mercator projection, each pixel spans the same amount of longitude, but a different amount of latitude. The artifacts you are experiencing are akin to a Tissot's indicatrix.
You can try using a different value for the raster-scaling symbolizer option in your tilemill stylesheet, but that's gonna make the artifacts different, not get rid of them.

How to warp a sector like area of an image into another sector like area using MATLAB?

I am trying to achieve, very crudely speaking, a stretching of borders of this shape:
All parameters (r,theta,delta(r), delta(theta)) can vary.
I've tried using fitgeotrans, projective2dand affine2d but they seem to work mostly for polygonal shapes.
Is it at all possible to use a polar coordinated image (using cart2pol) and then give polar points to fitgeotrans? Or is a polygon encapsulating the sector area the only option?
Ideally, you should do a back-warp. This means for each pixel in the dst image, find the corresponding pixel in the src and copy it there.
You could use pol2cart to do this, but it seems a little forced, since you have to do the adjustment yourself anyway.

Drawing image stamps along a path with Cairo

As part of my initial research, to see if using Cairo is a good fit for us, I'm looking to see if I can obtain an (x,y) point at a given distance from the start of a path. I have looked over the Cairo examples and APIs but I haven't found anything to suggest this is possible. It would be a pain if we had to build our own Bezier path implementation from scratch.
On android there is a class called PathMeasure. This allows getting an (x,y) point at a given distance from the start of the path. This allows me to draw a stamp easily at the wanted distance being able to produce something like the image below.
Hopefully someone can point me in the right direction.
Unless I have an uncomplete understanding of what you mean with "path", it seems that you can accomplish the task by starting from this guide. You would use multiple cr (image location, rotation, scale) and just one image instance.
From what I can understand from your image, you'll need to use blending (e.g. the alpha channel), I would say setting pixel by pixel the alpha channel (transparency) proportional to/same as your original grayscale values, and all the R G B pixels values to black (0).
For acting directly on your input image (on the file you will be loading), by googling "convert grayscale image to alpha" I found several results for Photoshop, some for gimp, I don't know what would you have available.
Otherwise you will have to do directly within your code accessing the image pixels. To read/edit pixel values you can use cairo_image_surface_get_data. First you have to create a destination image with cairo_image_surface_create
using format CAIRO_FORMAT_ARGB32
Similarly, you can use cairo_mask drawing a black rectangle of the size of your image, after having created an alpha channel image of format CAIRO_FORMAT_A8 from your original image (again, accessing pixel by pixel seems the only possible way given the limitations of cairo_image_surface_create_from_png).
Using cairo_paint_with_alpha in place of cairo_paint is not suitable because the alpha channel would be constant for the whole image.