Select to view content in your preferred language

Image to Real World Size CALCULATION

1242
7
Jump to solution
01-26-2024 01:18 AM
michaelkdev
Regular Contributor

Hi. I'm trying to figure out how to scale an image to the real world using visualVariables.

VisualVariables:
{
type: "size",
field: "WIDTH",
valueUnit: "meters"
},

Graphic A:

  • latitude: 51.27498953565823
  • longitude: 4.334665991886453
  • width: 100

michaelkdev_0-1706259986983.png


Graphic B:

  • latitude: 70.4059597
  • longitude: -22.488634
  • width: 100

michaelkdev_1-1706260287172.png

Both images have a width of 100 (in meters). The image is a base64 string with ratio 1x1 (1px).  And using visualVariables I would think these 2 images would have the same width/distance being 100 in meters or a scale taking the image ratio of 1x1 into account.

Can someone help me to calculate the correct scaled width based on geodesic and planar formulas?

Take 1. The width of graphicA would be something like 200 to get 100m and graphicB would have a width close to 400 to have a real width in meters of 100.

 

Thanks in advance

Gr

 

 

0 Kudos
1 Solution

Accepted Solutions
michaelkdev
Regular Contributor

The problem is the SIZE property of the CIM symbol. Now it's correct

 

michaelkdev_3-1706537193024.png

 

This is the CIM renderer

{
        type: "simple",
        symbol: {
          type: "cim",
          data: {
            type: "CIMSymbolReference",
            primitiveOverrides: [{
              type: "CIMPrimitiveOverride",
              primitiveName: "symbol-layer-1",
              propertyName: "ScaleX",
              valueExpressionInfo: {
                type: "CIMExpressionInfo",
                title: "Size override",
                expression: "1",
                returnType: "Numeric"
              }
            }],
            symbol: {
              "type": "CIMPointSymbol",
              "symbolLayers": [{
                "type": "CIMPictureMarker",
                primitiveName: "symbol-layer-1",
                "enable": true,
                "anchorPoint": {
                  "x": 0,
                  "y": 0
                },
                "anchorPointUnits": "Relative",
                "dominantSizeAxis3D": "Y",
                "billboardMode3D": "FaceNearPlane",
                "invertBackfaceTexture": true,
                size: 1,
                scaleX: 1,
                "textureFilter": "Picture",
                "tintColor": [
                  255,
                  255,
                  255,
                  255
                ],
                "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+L+U4T8ABu8CpCYJ1DQAAAAASUVORK5CYII="
              }]
            }
          },
        },
        label: "ships",
        visualVariables: [{
            type: "rotation",
            field: "ROTATION",
            rotationType: "geographic"
          },
          {
            type: "size",
            field: "WIDTH",
            valueUnit: "meters"
          },
        ]
      };


You should think the size property would override the size property of the CIM symbol? But It's not, when removing the size property of the CIM symbol It works. Can you explain this? Thanks

View solution in original post

0 Kudos
7 Replies
mleahy_cl
Regular Contributor

Are you doing this in a web map with a web mercator basemap?  I think if I understand the docs correctly, the size specified in the visual variable will be relative to the planar coordinates of the map the map view's spatial reference.  Web mercator, which nominally uses metres, will have a scale factor that gets increasingly exaggerated as you move towards the poles.

The measurement tool I believe is giving you geodesic measurements (i.e., the actual real-world ground distance, not measured in planar coordinates).

If you put your two graphics at the same latitude, they should have the same size.  If you position them somewhere along the equator, I think they will appear to be same width you specify in the visual variables.

If that proves to be the case, then I think specifying the symbol size this way will only work if you either use a local projected coordinate system for the map view, or perhaps there is a convenient way in arcade to convert the desired size to planar coordinate size (worst case, maybe use an equation that takes latitude into account to adjust the size value by scale factor).

0 Kudos
michaelkdev
Regular Contributor

Thanks!

Considering this image. This could be the correct way of thinking

michaelkdev_0-1706524893367.png

So Lets break this down 

  • latitude: 51.27498953565823
  • width of the symbol: 1 (in meters) - using visualVariables
  • image ratio width 1px

Step 1 Calculate the Scale Factor:

SF = 1 / cos(radians(51.27498953565823)) = 0.6255832662967687

 

Step 2 Calculate the Actual True Width:

ATW = Desired True Width / SF = 1 / 0.625583  = 1.5985

 

Using 1.59 as new scaled width. The actual width on my codepen measure tool is 0.75 meters.

75.png

 

 

0 Kudos
michaelkdev
Regular Contributor

Using a different latitude: 70.4059597 and calculating the ATW. I get 2.98 Real Width. Using this width instead of 1. The size I get with the measuring tool is also 0.75m

michaelkdev_1-1706525084840.png

Is Arcgis doing something special with the visualVariables here?

0 Kudos
michaelkdev
Regular Contributor

 @AnneFitz do you have an idea why 1px is translated to 0.75 meters keeping the calculations above in mind.

I'm using CIM symbol with visualVariable size WIDTH and scaleX 1

0 Kudos
michaelkdev
Regular Contributor

When using a simple marker instead of CIM with a base64 image. It's working with some distortion due to map projection I guess

Using simple marker:
https://codepen.io/michaelk95/pen/rNRpvLG

michaelkdev_0-1706535650180.png

 

Using CIM marker: 

michaelkdev_1-1706535721761.png

 

The base64 Image:

michaelkdev_2-1706535769760.png


All images are 3/4 of the original size?

 

0 Kudos
michaelkdev
Regular Contributor

The problem is the SIZE property of the CIM symbol. Now it's correct

 

michaelkdev_3-1706537193024.png

 

This is the CIM renderer

{
        type: "simple",
        symbol: {
          type: "cim",
          data: {
            type: "CIMSymbolReference",
            primitiveOverrides: [{
              type: "CIMPrimitiveOverride",
              primitiveName: "symbol-layer-1",
              propertyName: "ScaleX",
              valueExpressionInfo: {
                type: "CIMExpressionInfo",
                title: "Size override",
                expression: "1",
                returnType: "Numeric"
              }
            }],
            symbol: {
              "type": "CIMPointSymbol",
              "symbolLayers": [{
                "type": "CIMPictureMarker",
                primitiveName: "symbol-layer-1",
                "enable": true,
                "anchorPoint": {
                  "x": 0,
                  "y": 0
                },
                "anchorPointUnits": "Relative",
                "dominantSizeAxis3D": "Y",
                "billboardMode3D": "FaceNearPlane",
                "invertBackfaceTexture": true,
                size: 1,
                scaleX: 1,
                "textureFilter": "Picture",
                "tintColor": [
                  255,
                  255,
                  255,
                  255
                ],
                "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+L+U4T8ABu8CpCYJ1DQAAAAASUVORK5CYII="
              }]
            }
          },
        },
        label: "ships",
        visualVariables: [{
            type: "rotation",
            field: "ROTATION",
            rotationType: "geographic"
          },
          {
            type: "size",
            field: "WIDTH",
            valueUnit: "meters"
          },
        ]
      };


You should think the size property would override the size property of the CIM symbol? But It's not, when removing the size property of the CIM symbol It works. Can you explain this? Thanks

0 Kudos
mleahy_cl
Regular Contributor

Do you have a codepen of the working sample?  I'd be interested to have a look.

0 Kudos