Hi all! I have a CSV containing a set of values (Lat/Long, Name, Description, and Image URL) that I’d like to use to create a set of point entities with associated descriptions. I need to style it better than I could than by converting it into a GeoJSON, so I was planning to convert it into a JSON array and feed the values into viewer.entities.add to create the entities, but I don’t know where to start. Does anyone have a working example, or a better way of doing this?
Why can’t you use your CSV file directly and create entities from it?
Every CSV file is different, but I suppose that in each line you have Longitude and Latitude values, so you must know their position in the CSV.
CSV mean “comma separated values”, so each line is in this form:
in this example val1 is in position 1, val2 in position 2, val3 in position 3.
to retrieve these values you have to write (or use) a code that
read each line of your CSV
split each line by the comma in separated variables
get the longitude and latitude by these variables (but you must know their position in the CSV).
every longitude / latitude create an entity
So, let’s say that you have a CSV line like that:
someValue, 45.67786, 12.5667, someValue, someValue, someValue
you know that you have to get latitude from position 2, and longitude from position 3.
Usually the 1st line of the CSV give you the decription of the meaning of each position, for example:
So, for this example, you should read each line (but not the 1st one because it’s the description),
read the 2nd value (45.40804236744515) and put it in a variable “latitude”, read the 3rd value (12.366883160473764) and you put it in a variable “longitude”.
Next you can create an entity like that (if you want a billboard)
position: Cesium.Cartesian3.fromDegrees(longitude, latitude),
image: YOUR IMAGE,
width: YOUR WIDTH,
height: YOUR HEIGHT,