0

I'm not too familiar with the GeoJSON functionality in PostGIS.

In essence - I'm having problems with the computation of ST_AsGeoJSON(ST_Union(g)) taking too long for large g.

Is it possible to instead store the corresponding GeoJSONs alongside their geometries in a table, and then directly merge the GeoJSONs to get the desired end product?

Would that be faster than first computing the union of geometries then converting it to GeoJSON?

5
  • 1
    If you have polygons in (g) then ST_Union makes one big multipolygon from the whole table. Is that what you want to get? It would be hard to get the same output with direct merge of GeoJSONs.
    – user30184
    Apr 20 '16 at 13:03
  • 1
    Your suggestion would be much slower, as GeoJSON is a text format, and would also waste storage space, as it is simply a different representation of the same data. Unioning the binary geometries and then converting to GeoJSON will always be quicker. What do you mean by "taking too long". How big are the geometries and how long is it taking? Apr 20 '16 at 13:05
  • Yes, @user30184 - that's what I want to do. Apr 21 '16 at 7:51
  • @JohnBarça - it's the Berkeley GADM global shapefiles, and when (g) is chosen to be the union of 2 continents, for example, it takes several seconds to return the resulting GeoJSON. Apr 21 '16 at 8:11
  • Making an union from polygons does not involve heavy computations. I feat that for large g it just takes some time to read and rewrite the features and vertices. You can't avoid this data input/output by using GeoJSON as source format, in fact there will more i/o then. Several seconds does feel like a long time, though. How long does it take to output continent 1 + continent 2 as GeoJSON with separate requests?
    – user30184
    Apr 21 '16 at 8:17

Your Answer

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

Browse other questions tagged or ask your own question.