3

I know there is a way to load entities from a GeoJSON using GeoJsonDataSource but is there any way to do the opposite: get any entity as a GeoJSON representation?

My goal is to use Turf.JS with Cesium.JS geometries.

1
+500

Here you have a solution to export to json and for export it to kml.

Everything is obtained from this official thread of Cesium.

Update:

They are links that talk about the question and there isn't method to do that native in Cesium, such as exportKml. To implement exportJson (for example), it should be done using pure js or Turf as you did.

You can use the exportKml code to help create the result you are looking for.

Another way you can try is to export to KML and convert the result xml to json. For example using togeojson

Cesium.exportKml({
     entities: entityCollection
 })
  .then(function(result) {
    // The XML string is in result.kml
    // Convert Kml to GeoJSON (It's just an idea)
       json = toGeoJSON.kml(result)
  });

Note: If it is considered to be not a valid response, you can simply delete it or not accept it.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • 1
    Link-only answers are frowned upon because of linkrot and because it's often unclear which parts of a linked resource are actually relevant. – alphabetasoup Aug 28 at 7:07
  • 1
    I'll reward you not only because the quality of the answer but because you actualy answered something instead point your finger to my nose. Thankyou – Magno C Aug 30 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.