updating examples and descriptions for function examples

This commit is contained in:
Andy Eschbacher 2016-05-12 14:10:31 -04:00
parent b656569d51
commit e72c0521ea

View File

@ -28,9 +28,10 @@ If geometries are not found for the requested `polygon`, `geometry_id`, `timespa
#### Example #### Example
Get all Census Tracts in Lower Manhattan plus nearby areas within the supplied bounding box. Insert all Census Tracts from Lower Manhattan and nearby areas within the supplied bounding box to a table named `manhattan_census_tracts` which has columns `the_geom` (geometry) and `geoid` (text).
```sql ```sql
INSERT INTO manhattan_census_tracts(the_geom, geoid)
SELECT * SELECT *
FROM OBS_GetBoundariesByGeometry( FROM OBS_GetBoundariesByGeometry(
ST_MakeEnvelope(-74.0251922607,40.6945658517, ST_MakeEnvelope(-74.0251922607,40.6945658517,
@ -39,14 +40,6 @@ FROM OBS_GetBoundariesByGeometry(
'us.census.tiger.census_tract') 'us.census.tiger.census_tract')
``` ```
#### API Example
Retrieve all Census tracts contained in a bounding box around Denver, CO as a JSON response:
```text
http://observatory.cartodb.com/api/v2/sql?q=SELECT * FROM OBS_GetBoundariesByGeometry(ST_MakeEnvelope(-105.4287704158,39.4600507935,-104.5089737248,40.0901569675,4326),'us.census.tiger.census_tract', NULL, 'contains')
```
#### Errors #### Errors
* If a geometry other than a point is passed as the first argument, an error is thrown: `Invalid geometry type (ST_Polygon), expecting 'ST_Point'` * If a geometry other than a point is passed as the first argument, an error is thrown: `Invalid geometry type (ST_Polygon), expecting 'ST_Point'`
@ -78,9 +71,10 @@ If geometries are not found for the requested geometry, `geometry_id`, `timespan
#### Example #### Example
Get all Census Tracts in Lower Manhattan plus nearby areas within the supplied bounding box. Insert points that lie on Census Tracts from Lower Manhattan and nearby areas within the supplied bounding box to a table named `manhattan_census_tracts` which has columns `the_geom` (geometry) and `geoid` (text).
```sql ```sql
INSERT INTO manhattan_census_tract_points(the_geom, geoid)
SELECT * SELECT *
FROM OBS_GetPointsByGeometry( FROM OBS_GetPointsByGeometry(
ST_MakeEnvelope(-74.0251922607,40.6945658517, ST_MakeEnvelope(-74.0251922607,40.6945658517,
@ -89,14 +83,6 @@ FROM OBS_GetPointsByGeometry(
'us.census.tiger.census_tract') 'us.census.tiger.census_tract')
``` ```
#### API Example
Retrieve all Census tracts intersecting a bounding box around Denver, CO as a JSON response:
```text
http://observatory.cartodb.com/api/v2/sql?q=SELECT * FROM OBS_GetPointsByGeometry(ST_MakeEnvelope(-105.4287704158,39.4600507935,-104.5089737248,40.0901569675,4326), 'us.census.tiger.census_tract', NULL ,'contains')
```
#### Errors #### Errors
* If a geometry other than a point is passed as the first argument, an error is thrown: `Invalid geometry type (ST_Point), expecting 'ST_MultiPolygon' or 'ST_Polygon'` * If a geometry other than a point is passed as the first argument, an error is thrown: `Invalid geometry type (ST_Point), expecting 'ST_MultiPolygon' or 'ST_Polygon'`
@ -130,10 +116,6 @@ UPDATE tablename
SET the_geom = OBS_GetBoundary(the_geom, 'us.census.tiger.block_group') SET the_geom = OBS_GetBoundary(the_geom, 'us.census.tiger.block_group')
``` ```
<!--
Should add the SQL API call here too
-->
#### Errors #### Errors
* If a geometry other than a point is passed, an error is thrown: `Invalid geometry type (ST_Line), expecting 'ST_Point'` * If a geometry other than a point is passed, an error is thrown: `Invalid geometry type (ST_Line), expecting 'ST_Point'`
@ -160,17 +142,13 @@ geometry_id | a string identifier of a geometry in the Boundaries
#### Example #### Example
Write the geometry_id that contains the point geometry for every row as a new column in your table Write the US Census block group geoid that contains the point geometry for every row as a new column in your table.
```SQL ```SQL
UPDATE tablename UPDATE tablename
SET boundary_id = OBS_GetBoundaryId(the_geom, 'us.census.tiger.block_group') SET geometry_id = OBS_GetBoundaryId(the_geom, 'us.census.tiger.block_group')
``` ```
<!--
Include API examples
-->
#### Errors #### Errors
* If a geometry other than a point is passed, an error is thrown: `Invalid geometry type (ST_Line), expecting 'ST_Point'` * If a geometry other than a point is passed, an error is thrown: `Invalid geometry type (ST_Line), expecting 'ST_Point'`
@ -197,7 +175,7 @@ geom | a WGS84 polygon geometry
#### Example #### Example
Use a table of geometry_id to select the unique boundaries. Useful with the ```Create Dataset from Query``` option in CartoDB. Use a table of `geometry_id`s (e.g., geoid from the U.S. Census) to select the unique boundaries that they correspond to.
```SQL ```SQL
SELECT SELECT
@ -235,9 +213,10 @@ If geometries are not found for the requested point and radius, `geometry_id`, `
#### Example #### Example
Get Census tracts which intersect within 10 miles of Downtown, Colorado. In the Editor, you can simple use "Table from Query" to turn the result into a new dataset. Insert into table `denver_census_tracts` the census tract boundaries and geoids of census tracts which intersect within 10 miles of downtown Denver, Colorado.
```sql ```sql
INSERT INTO denver_census_tracts(the_geom, geoid)
SELECT * SELECT *
FROM OBS_GetBoundariesByPointAndRadius( FROM OBS_GetBoundariesByPointAndRadius(
CDB_LatLng(39.7392, -104.9903), -- Denver, Colorado CDB_LatLng(39.7392, -104.9903), -- Denver, Colorado
@ -276,9 +255,10 @@ If geometries are not found for the requested point and radius, `geometry_id`, `
#### Example #### Example
Get Census tracts which intersect within 10 miles of Downtown, Colorado. In the Editor, you can simple use "Table from Query" to turn the result into a new dataset. Insert into table `denver_census_tracts` points on US census tracts and their corresponding geoids for census tracts which intersect within 10 miles of downtown Denver, Colorado, USA.
```sql ```sql
INSERT INTO denver_census_tracts(the_geom, geoid)
SELECT * SELECT *
FROM OBS_GetPointsByPointAndRadius( FROM OBS_GetPointsByPointAndRadius(
CDB_LatLng(39.7392, -104.9903), -- Denver, Colorado CDB_LatLng(39.7392, -104.9903), -- Denver, Colorado