Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

Extent from db #112

Open
gjn opened this issue Aug 6, 2015 · 2 comments
Open

Extent from db #112

gjn opened this issue Aug 6, 2015 · 2 comments

Comments

@gjn
Copy link
Contributor

gjn commented Aug 6, 2015

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

@ltclm
Copy link
Contributor

ltclm commented Aug 6, 2015

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

@gjn
Copy link
Contributor Author

gjn commented Aug 6, 2015

Perfect. Thanks alot!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants