3d-forge icon indicating copy to clipboard operation
3d-forge copied to clipboard

Extent from db

Open gjn opened this issue 10 years ago • 2 comments

@ltclm Is there a simple query to get fully extent of all data in a table in the db?

gjn avatar Aug 06 '15 06:08 gjn

you can use this query to get the excact extent of a table [1]

Select st_extent(the_geom) FROM data.break_lines_16m
->
"BOX(7.47131324280926 46.6781819201024,8.2785583849303 47.1129888909493)"

The function will return a box, if you need a geometry you can do this:

Select st_setsrid(st_extent(the_geom),4326) FROM data.break_lines_16m

st_extent is an aggregate function and it returns the exact box, the bigger the table the longer it takes...

if it is sufficient to get an estimated value you can use this function instead [2]

select ST_EstimatedExtent('data','break_lines_16m','the_geom')

or for the geometry:

select st_setsrid(ST_EstimatedExtent('data','break_lines_16m','the_geom'),4326);

[1] http://postgis.net/docs/ST_Extent.html [2] http://postgis.net/docs/ST_EstimatedExtent.html

ltclm avatar Aug 06 '15 07:08 ltclm

Perfect. Thanks alot!

gjn avatar Aug 06 '15 07:08 gjn