select
st_transform(geom, 4326) as original,
st_chaikinsmoothing(st_transform(geom, 4326), 1) as one,
st_chaikinsmoothing(st_transform(geom, 4326), 5) as five
from
nyc_zips
limit
10
-- Find the first 50 trees in Fort Greene with the
-- Latitude and longitude columns
with a as (
select
latitude,
longitude
from
nyc_2015_tree_census
where
nta_name = 'Fort Greene'
limit
50
),
-- Turn the latitude/longitude columns into geometries
b as (
select
st_collect(
buildpoint(longitude :: numeric, latitude :: numeric, 4326)
) as geom
from
a
)
-- Create multiple concave hulls with various concave-ness
-- and use UNION to turn them into a single table
select
st_concavehull(geom, 0.1) as hull
from
b
union
select
st_concavehull(geom, 0.3) as hull
from
b
union
select
st_concavehull(geom, 0.7) as hull
from
b
with a as (
select
latitude,
longitude
from
nyc_2015_tree_census
where
nta_name = 'Fort Greene'
limit
50
), b as (
select
st_collect(
buildpoint(longitude :: numeric, latitude :: numeric, 4326)
) as geom
from
a
)
select
st_convexhull(geom) as hull
from
b
-- Create multiple geometries with different simplification levels
-- and UNION them into one table
select
st_transform(geom, 4326) as geom
from
nyc_zips
where
zipcode = '11693'
union
select
st_transform(st_simplify(geom, 1), 4326) as geom
from
nyc_zips
where
zipcode = '11693'
union
select
st_transform(st_simplify(geom, 10), 4326) as geom
from
nyc_zips
where
zipcode = '11693'
union
select
st_transform(st_simplify(geom, 50), 4326) as geom
from
nyc_zips
where
zipcode = '11693'
-- Create multiple geometries that share borders with different
-- simplification levels and UNION them into one table
select
st_transform(geom, 4326) as geom
from
nyc_zips
where
zipcode = '11434'
or st_touches(
geom,
(
select
geom
from
nyc_zips
where
zipcode = '11434'
)
)
union
select
st_transform(st_simplifypreservetopology(geom, 1), 4326) as geom
from
nyc_zips
where
zipcode = '11434'
or st_touches(
geom,
(
select
geom
from
nyc_zips
where
zipcode = '11434'
)
)
union
select
st_transform(st_simplifypreservetopology(geom, 10), 4326) as geom
from
nyc_zips
where
zipcode = '11434'
or st_touches(
geom,
(
select
geom
from
nyc_zips
where
zipcode = '11434'
)
)
union
select
st_transform(st_simplifypreservetopology(geom, 50), 4326) as geom
from
nyc_zips
where
zipcode = '11434'
or st_touches(
geom,
(
select
geom
from
nyc_zips
where
zipcode = '11434'
)
)