Select to view content in your preferred language

Joining CSV tables to a static set of geometry to create a time enabled layer

292
0
06-20-2022 04:57 PM
PhilipWeeks
New Contributor III

I’m adding functionality to a JavaScript API web application to take some rainfall forecast information and display it.  Since it’s updated every hour and I didn’t want to have something doing server side processing and creating layers every interval, I wanted to have the website pull the most current information via client side processing.  The information comes in two pieces, a set of forecast lat/lons locations in a grid which will be static, and the list of forecasts for those points arrayed in the same order as those points, repeating around 18 times in 1-hour intervals.

My current method is to loop through all the forecast arrays and create points by referencing the static locations for each time interval into one big in memory CSV which can be time-enabled and symbolized accordingly.  This may already be a bad idea since with a grid of 24x33 and 18 time intervals my CSV has about 14k rows.  Since only one interval will ever be displayed that's only around 792 points but I'm not sure how much is too much when trying to do stuff client side with CSV layers.

However, since these points are arranged in a grid, instead of points I wanted the forecast data to be displayed as the grid rectangles.  I’ve created the static set of polygons using Thiessen polygons and can host them, but the challenge now would be using them and the CSV of forecasts to dynamically create a time-enabled layer of polygons.

I can do something similar, take a GeoJSON version of the static polygon layer, loop through the forecast arrays and create a set of polygons for each time interval in one big in-memory GeoJSON and make it time enabled, but I’m wondering if there’s a better approach.  I would really like to be able to just take the forecast .csv, convert it into a table, and then do some sort of join to the polygons but I’m not even sure if that’s doable in the JS API, and it's further complicated by needed to do a one to many join as each polygon will need to have an entity for each forecast time interval.

Edit: I am also considering just going with server side processing with something like PHP to return a GeoJSON of the polygons joined with all the time-enabled data, but I'm still curious if that's the better approach or if there's other better ways of dealing with dynamic tables of time data with a static set of geometries.

0 Kudos
0 Replies