# Moving geometry with epoch

**URL:** <https://community.cesium.com/t/moving-geometry-with-epoch/36267>\
**Category:** CesiumJS\
**Created:** [November 1, 2024, 5:26pm UTC](https://community.cesium.com/t/moving-geometry-with-epoch/36267 "2024-11-01T17:26:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SolventDrip](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/solventdrip/32/14000_2.png) [@SolventDrip](https://community.cesium.com/u/SolventDrip)\
**Post date:** [November 1, 2024, 5:26pm UTC](https://community.cesium.com/t/moving-geometry-with-epoch/36267/1 "2024-11-01T17:26:48Z")

</div>

I am trying to move a geometry along with my billboard and label. I’m creating czml files in python and I’m trying to add an ellipsoid to to follow a satellite I’m looking at.

So if I have two objects like so:

 ![image](https://global.discourse-cdn.com/cesium/original/3X/3/d/3d8ee6d9b59bc7cd1e6457ab19f01a10bd8232e7.jpeg)  
I would like to draw a 100m sphere around them to get a sense of scale.

If a line could be drawn and the length of that line is returned with each epoch that would also be of interest.

---

<div class="post-metadata">

**Author:** ![Luke\_McKinstry](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/luke_mckinstry/32/25557_2.png) [@Luke\_McKinstry](https://community.cesium.com/u/Luke_McKinstry)\
**Post date:** [November 1, 2024, 6:23pm UTC](https://community.cesium.com/t/moving-geometry-with-epoch/36267/2 "2024-11-01T18:23:30Z")

</div>

Hi @SolventDrip ,  
Thanks for your post and welcome to the Cesium community.

For adding a sphere at the same location as your CZML models, you could use an entity. This sandcastle example [Cesium Sandcastle](https://sandcastle.cesium.com/?src=Spheres%20and%20Ellipsoids.html) shows how to create and position a Sphere Entity. For drawing a line between the two models you could use a Polyline Entity [Cesium Sandcastle](https://sandcastle.cesium.com/?src=Polyline.html).

I hope that helps and please let us know if you have further questions.  
Thanks,  
Luke

---

<div class="post-metadata">

**Author:** ![SolventDrip](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/solventdrip/32/14000_2.png) [@SolventDrip](https://community.cesium.com/u/SolventDrip)\
**Post date:** [November 6, 2024, 11:43am UTC](https://community.cesium.com/t/moving-geometry-with-epoch/36267/3 "2024-11-06T11:43:09Z")

</div>

Hi Luke,

Thanks for your response. I saw that example on the sphere but I don’t see where/how it shows anything about linking/attaching a sphere to an object inside a `.czml` file and updates its position w.r.t. the other object.

---

<div class="post-metadata">

**Author:** ![SolventDrip](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/solventdrip/32/14000_2.png) [@SolventDrip](https://community.cesium.com/u/SolventDrip)\
**Post date:** [November 6, 2024, 12:04pm UTC](https://community.cesium.com/t/moving-geometry-with-epoch/36267/4 "2024-11-06T12:04:08Z")

</div>

Like, right now (working in python) I’m working through some data and appending it to a list in the czml format before encoding it into a json file. The data works through a forloop of “sources” and what I’m doing right now is appending it to the list.

```python
for source in sources:
   d_czml.append(
      {
         'id': {source},
          ... # building data packet
      }
   )

   # The sphere that's supposed to follow the packet data below:
   d_czml.append(
    {
      "id": f"{source}_sphere",
      "name": f"Sphere Around {source}",
      "parent": f"{source}",
      "position": {
        "reference": f"{source}#position"
      },
      "ellipsoid": {
        "radii": {
          "cartesian": [100, 100, 100]
        },
        "material": {
          "solidColor": {
            "color": {
              # "rgba": [0, 0, 255, 50] # Semi-transparent blue
              "rgba": colour[i][:2] + [50]
            }
          }
        },
        "outline": True,
        "outlineColor": {
          # "rgba": [0, 0, 255, 200]
          "rgba": colour[i][:2] + [200]
        }
      }
    }
  )

with open(data_dir / 'test_czml.czml', 'w') as f:
  f.write(json.dumps(d_czml))

```

The datapacket section works perfectly (as shown in my OP) but this section that’s meant to add the sphere runs a julianDate error so it’s not working correctly somewhere.

 ![image](https://global.discourse-cdn.com/cesium/original/3X/2/3/2357462d1afbb0355f6f0e3ad062295e438d8ad1.jpeg)

I did try and add it in with the “billboard” or around there and it didn’t show the sphere.

Where the (formatted for readability) source position data looks something like:

```json
"position": {
   "interpolationAlgorithm": "LAGRANGE", 
   "interpolationDegree": 5, 
   "referenceFrame": "INERTIAL", 
   "cartesian": [
      "2022-12-28T00:03:00Z", -4393036.524, -1978967.914, -5183191.302, 
      "2022-12-28T00:06:00Z", -3570742.247, -1244795.108, -5981621.194999999, 
      "2022-12-28T00:09:00Z", -2600203.0840000003, -489291.636, -6562897.401000001, 
      "2022-12-28T00:12:00Z", -1516309.833, 256866.49599999998, -6906091.258, 
      "2022-12-28T00:15:00Z", -358739.081, 964354.078, -6998806.908, 
      "2022-12-28T00:18:00Z", 829466.275, 1606315.0080000001, -6837589.348, 
      "2022-12-28T00:21:00Z", 2003449.1479999998, 2159355.638, -6428057.665, 
      "2022-12-28T00:24:00Z", 3118191.8260000004, 2604388.785, -5784752.687, 
      "2022-12-28T00:27:00Z", 4130217.504, 2927299.5409999997, 
      ...,
   ],
}

```

---

<div class="post-metadata">

**Author:** ![SolventDrip](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/solventdrip/32/14000_2.png) [@SolventDrip](https://community.cesium.com/u/SolventDrip)\
**Post date:** [November 6, 2024, 2:00pm UTC](https://community.cesium.com/t/moving-geometry-with-epoch/36267/5 "2024-11-06T14:00:33Z")

</div>

Got it.  
Problem was when I was calling the colours with:

```py
colour[i][:2] + [50]

```

it was only calling the first two elements (RG) and then adds the “Alpha” layer of the list where what I needed to do was call:

```py
colour[i][:3] + [50]

```

to call the first 3 elements (the RGB and then adds the Alpha layer)

 ![image](https://global.discourse-cdn.com/cesium/original/3X/7/1/716c053ec6ea250c71619edd361c0964a70bc8ce.jpeg)
