Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
pedrohenriqueperna
Creator III
Creator III

Help plotting background image (SOS)

Hi, I'm having a hard time trying to display a floor plan in a map object. Basically I want to show the floor plan and then build some shp or kml in QGIS to plot over the image and have selectable areas, etc.

The expected output would be something like this:

therealdees_0-1734016901564.png

 

I'm just very lost. I found and followed multiple tutorials, but most of them is using Qlik Desktop and I'm on SaaS. They are also from 6-8 years ago, so it's probably different now, there are new connectors, etc.

My main struggle is showing the image. The image has 1920x1080px, so I've set it like this (saw it in a post):

therealdees_1-1734017132098.png

I've set the map to use "none" as base and "user defined meters" as projection. I made it work a couple times, but I'm assuming the image is too small comparing to the "base" map. I guess I just lost the image in the map and the "home" button doesn't even click, it's just grayed out. I've managed to display it and then started trying to add the area layer, but the map then moves/zooms and I guess I lose the image somewhere.

I'm pretty sure this is possible I'm just getting crazy, please help.

 

How can I have a big enough image over the map so I don't "lose" it around?

How can I match the area layer coordinates to the image?

 

PS: I've attached the image and the KML in case an angel would be willing to share a qvf

 

Labels (5)
1 Solution

Accepted Solutions
pedrohenriqueperna
Creator III
Creator III
Author

Ok I've got it to work. If anyone's trying to do the same, here's how I've done it:

Basically you need to convert pixels to latitude and longitude coordinates. I've used the following formula:

Round((RangeMax(vWidth,vHeight) / 2 - vWidth / 2 + x1) * 40075014 / RangeMax(vWidth,vHeight) - 20037507)

Where vWidth and vHeight are the image/area size. My image has 1917x897 pixels, so that's my vWidth and vHeight.

 

1. Set the base map settings to "none"; projection to "user defined meters"; units of measurement to "metric"

2. Add the image as a background layer. You need an URL to do this. You can upload your image to imgur.com. Last time I've checked, they won't delete the image after sometime. It'll be there "forever".

3. You must add the url domain to your Content Security Policy, under the Administration Settings. It's a security setting that will allow data from that domain.

therealdees_5-1734367024993.png

 

4. After that, your image will be somewhere in the map, but not in the correct resolution/size. You must set the coordinates for it using the conversion formula. I've added the same formula to a variable so I can use it in the expressions:

SET fX2Long = Round((RangeMax($2,$3)/2 - $2/2 + $1) * 40075014 / RangeMax($2,$3) - 20037507);
SET fY2Lat = Round((RangeMax($2,$3)/2- $3/2 + $1) * -40075014 / RangeMax($2,$3) + 20037507);

This formula basically transforms single points in pixels to coordinates, where the first value is the x or y, and the other 2 values are the max width and max height you've set before.

therealdees_0-1734365992560.png

5. Now you need to add a new layer to display the points/area on top of the image. Basically, you need to find out in your image what exact pixel is your point at. You can use photoshop do to this, using "rulers". I've used a free software called IrfanView. A point is a single x,y coordinate, so it'd be easier. After you find out what pixel your point's at, just add the new point layer to the map and use the same formula.

therealdees_1-1734366495999.png

You can have the values in a table, as I did, or you can hardcode the values as I did to the image layer.

It gets a bit more complicated if you want to display an area layer. An area layer is basically an array of x,y coordinates and looks like this:

therealdees_2-1734366569646.png

In my case, I've created a table (could be inline) and I do the calculation while loading the table, so I can combine the different points (I've used the same formula, but this time while loading, instead of calling the function that is saved in a variable):

therealdees_3-1734366687915.png

Zone:
LOAD
temp_tile as tile,
'[[' & x1_calc & ',' & y1_calc & '],[' & x2_calc & ',' & y2_calc & '],[' & x3_calc & ',' & y3_calc & '],[' & x4_calc & ',' & y4_calc & ']]' as area_polygon;
LOAD
tile as temp_tile,
x1,
Round((RangeMax(vWidth,vHeight) / 2 - vWidth / 2 + x1) * 40075014 / RangeMax(vWidth,vHeight) - 20037507) as x1_calc,
y1,
Round((RangeMax(vWidth,vHeight) / 2 - vHeight / 2 + y1) * -40075014 / RangeMax(vWidth,vHeight) + 20037507) as y1_calc,
x2,
Round((RangeMax(vWidth,vHeight) / 2 - vWidth / 2 + x2) * 40075014 / RangeMax(vWidth,vHeight) - 20037507) as x2_calc,
y2,
Round((RangeMax(vWidth,vHeight) / 2 - vHeight / 2 + y2) * -40075014 / RangeMax(vWidth,vHeight) + 20037507) as y2_calc,
x3,
Round((RangeMax(vWidth,vHeight) / 2 - vWidth / 2 + x3) * 40075014 / RangeMax(vWidth,vHeight) - 20037507) as x3_calc,
y3,
Round((RangeMax(vWidth,vHeight) / 2 - vHeight / 2 + y3) * -40075014 / RangeMax(vWidth,vHeight) + 20037507) as y3_calc,
x3,
Round((RangeMax(vWidth,vHeight) / 2 - vWidth / 2 + x4) * 40075014 / RangeMax(vWidth,vHeight) - 20037507) as x4_calc,
y4,
Round((RangeMax(vWidth,vHeight) / 2 - vHeight / 2 + y4) * -40075014 / RangeMax(vWidth,vHeight) + 20037507) as y4_calc
FROM [lib://ETL:Google Drive/xxx/area_plantas.xlsx]
(ooxml, embedded labels, table is Sheet1);

PS: I've added the vWidth and vHeight directly in the table because expanding the variable (like this '$(vWidth)') wasn't giving me any values for some reason.

6. After you create the polygon/field holding every value, then add the new area layer and set area_id as the dimension and the area_polygon as the coordinates and it should magically work.

therealdees_4-1734366799092.png

7. Note that I'm working with squares/rectangles, which is easier because you can define only 4 points inside the polygon, but you can work with whatever shape, you just have to load and convert more points to form your polygon.

Instead of 4 (x1,y1 to x4,y4), this line would have n other points:

'[[' & x1_calc & ',' & y1_calc & '],[' & x2_calc & ',' & y2_calc & '],[' & x3_calc & ',' & y3_calc & '],[' & x4_calc & ',' & y4_calc & ']]' as area_polygon

View solution in original post

1 Reply
pedrohenriqueperna
Creator III
Creator III
Author

Ok I've got it to work. If anyone's trying to do the same, here's how I've done it:

Basically you need to convert pixels to latitude and longitude coordinates. I've used the following formula:

Round((RangeMax(vWidth,vHeight) / 2 - vWidth / 2 + x1) * 40075014 / RangeMax(vWidth,vHeight) - 20037507)

Where vWidth and vHeight are the image/area size. My image has 1917x897 pixels, so that's my vWidth and vHeight.

 

1. Set the base map settings to "none"; projection to "user defined meters"; units of measurement to "metric"

2. Add the image as a background layer. You need an URL to do this. You can upload your image to imgur.com. Last time I've checked, they won't delete the image after sometime. It'll be there "forever".

3. You must add the url domain to your Content Security Policy, under the Administration Settings. It's a security setting that will allow data from that domain.

therealdees_5-1734367024993.png

 

4. After that, your image will be somewhere in the map, but not in the correct resolution/size. You must set the coordinates for it using the conversion formula. I've added the same formula to a variable so I can use it in the expressions:

SET fX2Long = Round((RangeMax($2,$3)/2 - $2/2 + $1) * 40075014 / RangeMax($2,$3) - 20037507);
SET fY2Lat = Round((RangeMax($2,$3)/2- $3/2 + $1) * -40075014 / RangeMax($2,$3) + 20037507);

This formula basically transforms single points in pixels to coordinates, where the first value is the x or y, and the other 2 values are the max width and max height you've set before.

therealdees_0-1734365992560.png

5. Now you need to add a new layer to display the points/area on top of the image. Basically, you need to find out in your image what exact pixel is your point at. You can use photoshop do to this, using "rulers". I've used a free software called IrfanView. A point is a single x,y coordinate, so it'd be easier. After you find out what pixel your point's at, just add the new point layer to the map and use the same formula.

therealdees_1-1734366495999.png

You can have the values in a table, as I did, or you can hardcode the values as I did to the image layer.

It gets a bit more complicated if you want to display an area layer. An area layer is basically an array of x,y coordinates and looks like this:

therealdees_2-1734366569646.png

In my case, I've created a table (could be inline) and I do the calculation while loading the table, so I can combine the different points (I've used the same formula, but this time while loading, instead of calling the function that is saved in a variable):

therealdees_3-1734366687915.png

Zone:
LOAD
temp_tile as tile,
'[[' & x1_calc & ',' & y1_calc & '],[' & x2_calc & ',' & y2_calc & '],[' & x3_calc & ',' & y3_calc & '],[' & x4_calc & ',' & y4_calc & ']]' as area_polygon;
LOAD
tile as temp_tile,
x1,
Round((RangeMax(vWidth,vHeight) / 2 - vWidth / 2 + x1) * 40075014 / RangeMax(vWidth,vHeight) - 20037507) as x1_calc,
y1,
Round((RangeMax(vWidth,vHeight) / 2 - vHeight / 2 + y1) * -40075014 / RangeMax(vWidth,vHeight) + 20037507) as y1_calc,
x2,
Round((RangeMax(vWidth,vHeight) / 2 - vWidth / 2 + x2) * 40075014 / RangeMax(vWidth,vHeight) - 20037507) as x2_calc,
y2,
Round((RangeMax(vWidth,vHeight) / 2 - vHeight / 2 + y2) * -40075014 / RangeMax(vWidth,vHeight) + 20037507) as y2_calc,
x3,
Round((RangeMax(vWidth,vHeight) / 2 - vWidth / 2 + x3) * 40075014 / RangeMax(vWidth,vHeight) - 20037507) as x3_calc,
y3,
Round((RangeMax(vWidth,vHeight) / 2 - vHeight / 2 + y3) * -40075014 / RangeMax(vWidth,vHeight) + 20037507) as y3_calc,
x3,
Round((RangeMax(vWidth,vHeight) / 2 - vWidth / 2 + x4) * 40075014 / RangeMax(vWidth,vHeight) - 20037507) as x4_calc,
y4,
Round((RangeMax(vWidth,vHeight) / 2 - vHeight / 2 + y4) * -40075014 / RangeMax(vWidth,vHeight) + 20037507) as y4_calc
FROM [lib://ETL:Google Drive/xxx/area_plantas.xlsx]
(ooxml, embedded labels, table is Sheet1);

PS: I've added the vWidth and vHeight directly in the table because expanding the variable (like this '$(vWidth)') wasn't giving me any values for some reason.

6. After you create the polygon/field holding every value, then add the new area layer and set area_id as the dimension and the area_polygon as the coordinates and it should magically work.

therealdees_4-1734366799092.png

7. Note that I'm working with squares/rectangles, which is easier because you can define only 4 points inside the polygon, but you can work with whatever shape, you just have to load and convert more points to form your polygon.

Instead of 4 (x1,y1 to x4,y4), this line would have n other points:

'[[' & x1_calc & ',' & y1_calc & '],[' & x2_calc & ',' & y2_calc & '],[' & x3_calc & ',' & y3_calc & '],[' & x4_calc & ',' & y4_calc & ']]' as area_polygon