From e70794a6207e26b8a682a5d4cbeb2b91d3f217bd Mon Sep 17 00:00:00 2001 From: csobier Date: Tue, 26 Apr 2016 12:31:08 -0400 Subject: [PATCH 1/8] added best practices as an H3 under the Overview, data services api integration section --- doc/geocoding_functions.md | 2 +- doc/isoline_functions.md | 2 +- doc/overview.md | 10 +++++++++- doc/quota_information.md | 5 ++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/doc/geocoding_functions.md b/doc/geocoding_functions.md index d4dffc2..d7f5dcc 100644 --- a/doc/geocoding_functions.md +++ b/doc/geocoding_functions.md @@ -2,7 +2,7 @@ The [geocoder](https://cartodb.com/data/geocoder-api/) functions allow you to match your data with geometries on your map. This geocoding service can be used programatically to geocode datasets via the CartoDB SQL API. It is fed from _Open Data_ and it serves geometries for countries, provinces, states, cities, postal codes, IP addresses and street addresses. CartoDB provides functions for several different categories of geocoding through the Data Services API. -_**This service is subject to quota limitations, and extra fees may apply**. View the [Quota Information](http://docs.cartodb.com/cartodb-platform/dataservices-api/quota-information/) section for details, and recommendations, about to quota consumption._ +_**This service is subject to quota limitations and extra fees may apply**. View the [Quota Information](http://docs.cartodb.com/cartodb-platform/dataservices-api/quota-information/) section for details and recommendations about to quota consumption._ Here is an example of how to geocode a single country: diff --git a/doc/isoline_functions.md b/doc/isoline_functions.md index 3077260..9438e83 100644 --- a/doc/isoline_functions.md +++ b/doc/isoline_functions.md @@ -2,7 +2,7 @@ [Isolines](https://cartodb.com/data/isolines/) are contoured lines that display equally calculated levels over a given surface area. This enables you to view polygon dimensions by forward or reverse measurements. Isoline functions are calculated as the intersection of areas from the origin point, measured by distance (isodistance) or time (isochrone). For example, the distance of a road from a sidewalk. Isoline services through CartoDB are available by requesting a single function in the Data Services API. -_**This service is subject to quota limitations, and extra fees may apply**. View the [Quota Information](http://docs.cartodb.com/cartodb-platform/dataservices-api/quota-information/) section for details, and recommendations, about to quota consumption._ +_**This service is subject to quota limitations and extra fees may apply**. View the [Quota Information](http://docs.cartodb.com/cartodb-platform/dataservices-api/quota-information/) section for details and recommendations about to quota consumption._ You can use the isoline functions to retrieve, for example, isochrone lines from a certain location, specifying the mode and the ranges that will define each of the isolines. The following query calculates isolines for areas that are 5, 10 and 15 minutes (300, 600 and 900 seconds, respectively) away from the location by following a path defined by car routing. polygon({country_column})&api_key={api_key} diff --git a/doc/overview.md b/doc/overview.md index 3c59ef9..c19aff9 100644 --- a/doc/overview.md +++ b/doc/overview.md @@ -1,6 +1,6 @@ # Overview -By using CartoDB libraries and the SQL API, you can apply location data services to your maps with select functions. These functions are integrated with a number of internal and external services, enabling you to programatically customize subsets of data for your visualizations. For example, you can transform an address to a geometry with [geocoding functions](http://docs.cartodb.com/cartodb-platform/dataservices-api/geocoding-functions/#geocoding-functions). You can also use [isoline functions](http://docs.cartodb.com/cartodb-platform/dataservices-api/isoline-functions/#isoline-functions) to calculate the travel distance for a defined area. These features are useful for geospatial analysis and the results can be saved, and stored, for additional location data service operations. +By using CartoDB libraries and the SQL API, you can apply location data services to your maps with select functions. These functions are integrated with a number of internal and external services, enabling you to programatically customize subsets of data for your visualizations. These features are useful for geospatial analysis and the results can be saved, and stored, for additional location data service operations. **Note:** Based on your account plan, some of these data services are subject to different [quota limitations](http://docs.cartodb.com/cartodb-platform/dataservices-api/quota-information/#quota-information). @@ -16,6 +16,14 @@ The geometries provided by this API are projected in the projection [WGS 84 SRID **Note:** The Data Services API [geocoding functions](http://docs.cartodb.com/cartodb-platform/dataservices-api/geocoding-functions/#geocoding-functions) return different types of geometries (points or polygons) as result of different geocoding processes. The CartoDB Platform does not support multi-geometry layers or datasets, therefore you must confirm that you are using consistent geometry types inside a table, to avoid future conflicts in your map visualization. +### Best Practices + +_Be mindful of the following usage notes when using the Data Services functions with the SQL API:_ + +If you are using SELECT functions with the Data Services API, these queries consume quota when rendering tiles for your live map views. Additionally, it requires that you need an API Key and can slow down sync performance, due to executing multiple requests to the API each time your map is viewed. See details about [Quota Consumption](http://docs.cartodb.com/cartodb-platform/dataservices-api/quota-information/#quota-consumption). + +The Data Services API is **recommended** to be used with INSERT or UPDATE. While SELECT (retrieve) is standard for SQL API requests, be mindful of quota consumption and use INSERT (to insert a new record) or UPDATE (to update an existing record), for best practices. + ## Authentication All requests performed to the CartoDB Data Services API must be authenticated with the user API Key. For more information about where to find your API Key, and how to authenticate your SQL API requests, view the [SQL API authentication](/cartodb-platform/sql-api/authentication/) documentation. diff --git a/doc/quota_information.md b/doc/quota_information.md index 917af9a..e87dca1 100644 --- a/doc/quota_information.md +++ b/doc/quota_information.md @@ -7,5 +7,8 @@ Quota consumption is calculated based on the number of request made for each function. Be mindful of the following usage recommendations when using the Data Services API functions: * One credit per function call will be consumed. The results are not cached. If the query is applied to a _N_ rows dataset, then _N_ credits are consumed -* Avoid running dynamic queries to these functions in your maps. This can result in credit consumption per map view. **Note:** Queries to the Data Services API, and any of its functions in your maps, may be forbidden in the future +* Avoid running dynamic queries to these functions in your maps. This can result in credit consumption per map view. + + **Note:** Queries to the Data Services API, and any of its functions in your maps, may be forbidden in the future + * It is advised to store results of these queries into your datasets, and refresh them as needed. This ensure more control of quota credits for your account From ae109a8cdcd1c3c4d921b09e86391f4a4e735893 Mon Sep 17 00:00:00 2001 From: csobier Date: Tue, 26 Apr 2016 14:26:29 -0400 Subject: [PATCH 2/8] edited overview and best practices section for clarity --- doc/overview.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/overview.md b/doc/overview.md index c19aff9..447624d 100644 --- a/doc/overview.md +++ b/doc/overview.md @@ -1,6 +1,6 @@ # Overview -By using CartoDB libraries and the SQL API, you can apply location data services to your maps with select functions. These functions are integrated with a number of internal and external services, enabling you to programatically customize subsets of data for your visualizations. These features are useful for geospatial analysis and the results can be saved, and stored, for additional location data service operations. +By using CartoDB libraries and the SQL API, you can apply location data services to your maps with unique data services functions. These functions are integrated with a number of internal and external services, enabling you to programatically customize subsets of data for your visualizations. These features are useful for geospatial analysis and the results can be saved, and stored, for additional location data service operations. **Note:** Based on your account plan, some of these data services are subject to different [quota limitations](http://docs.cartodb.com/cartodb-platform/dataservices-api/quota-information/#quota-information). @@ -20,9 +20,9 @@ The geometries provided by this API are projected in the projection [WGS 84 SRID _Be mindful of the following usage notes when using the Data Services functions with the SQL API:_ -If you are using SELECT functions with the Data Services API, these queries consume quota when rendering tiles for your live map views. Additionally, it requires that you need an API Key and can slow down sync performance, due to executing multiple requests to the API each time your map is viewed. See details about [Quota Consumption](http://docs.cartodb.com/cartodb-platform/dataservices-api/quota-information/#quota-consumption). +It is discouraged to use the SELECT operation with the Data Services API functions, as these type of queries consume quota when rendering tiles for your live map views. It may also result in sync performance issues, due to executing multiple requests to the API each time your map is viewed. See details about [Quota Consumption](http://docs.cartodb.com/cartodb-platform/dataservices-api/quota-information/#quota-consumption). -The Data Services API is **recommended** to be used with INSERT or UPDATE. While SELECT (retrieve) is standard for SQL API requests, be mindful of quota consumption and use INSERT (to insert a new record) or UPDATE (to update an existing record), for best practices. +The Data Services API is **recommended** to be used with INSERT or UPDATE operations. While SELECT (retrieve) is standard for SQL API requests, be mindful of quota consumption and use INSERT (to insert a new record) or UPDATE (to update an existing record), for best practices. ## Authentication From ee3913dd86bb1b22b5541a4a21ecf07ba4dbcabb Mon Sep 17 00:00:00 2001 From: csobier Date: Thu, 28 Apr 2016 09:47:26 -0400 Subject: [PATCH 3/8] applied edits to overview based on Carlas review --- doc/overview.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/overview.md b/doc/overview.md index 447624d..ed9d307 100644 --- a/doc/overview.md +++ b/doc/overview.md @@ -20,9 +20,9 @@ The geometries provided by this API are projected in the projection [WGS 84 SRID _Be mindful of the following usage notes when using the Data Services functions with the SQL API:_ -It is discouraged to use the SELECT operation with the Data Services API functions, as these type of queries consume quota when rendering tiles for your live map views. It may also result in sync performance issues, due to executing multiple requests to the API each time your map is viewed. See details about [Quota Consumption](http://docs.cartodb.com/cartodb-platform/dataservices-api/quota-information/#quota-consumption). +It is discouraged to use the SELECT operation with the Data Services API functions in your map layers, as these type of queries consume quota when rendering tiles for your live map views. It may also result in sync performance issues, due to executing multiple requests to the API each time your map is viewed. See details about [Quota Consumption](http://docs.cartodb.com/cartodb-platform/dataservices-api/quota-information/#quota-consumption). -The Data Services API is **recommended** to be used with INSERT or UPDATE operations. While SELECT (retrieve) is standard for SQL API requests, be mindful of quota consumption and use INSERT (to insert a new record) or UPDATE (to update an existing record), for best practices. +The Data Services API is **recommended** to be used with INSERT or UPDATE operations, for applying location data to your tables. While SELECT (retrieve) is standard for SQL API requests, be mindful of quota consumption and use INSERT (to insert a new record) or UPDATE (to update an existing record), for best practices. ## Authentication From a6de16449f579b12aa74beb37d37d9574e458fcf Mon Sep 17 00:00:00 2001 From: Carla Iriberri Date: Wed, 4 May 2016 19:52:22 +0200 Subject: [PATCH 4/8] Removing select statements --- doc/isoline_functions.md | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/doc/isoline_functions.md b/doc/isoline_functions.md index 9438e83..d1f4f08 100644 --- a/doc/isoline_functions.md +++ b/doc/isoline_functions.md @@ -43,20 +43,16 @@ Name | Type | Description #### Examples -##### Select the results of the isodistance function +##### Calculate and insert isodistance polygons from a point into another table ```bash -SELECT * FROM cdb_isodistance('POINT(-3.70568 40.42028)'::geometry, 'car', ARRAY[1000,2000]::integer[]); +INSERT INTO {table} (the_geom) SELECT the_geom FROM cdb_isodistance('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300, 600, 900]::integer[]) ``` -```bash -SELECT * FROM cdb_isodistance('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[1000]::integer[], ARRAY['mode_traffic=enabled','quality=3']::text[]); -``` - -##### Select the geometric results of the isodistance function +or equivalently: ```bash -SELECT the_geom FROM cdb_isodistance('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[1000]::integer[]); +INSERT INTO {table} (the_geom) SELECT (cdb_isodistance('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300, 600, 900]::integer[])).the_geom ``` ##### Calculate and insert the generated isolines from `points_table` table to another table @@ -65,6 +61,7 @@ SELECT the_geom FROM cdb_isodistance('POINT(-3.70568 40.42028)'::geometry, 'walk INSERT INTO {table} (the_geom) SELECT (cdb_isodistance(the_geom, 'walk', string_to_array(distance, ',')::integer[])).the_geom FROM {points_table} ``` + ## cdb_isochrone(_source geometry, mode text, range integer[], [options text[]]_) Displays a contoured line on a map, connecting geometries to a defined area, measured by an equal range of time (in seconds). @@ -82,23 +79,19 @@ Name | Type | Description | Accepted values #### Examples -##### Select the results of the isochrone function +##### Calculate and insert isochrone polygons from a point into another table ```bash -SELECT * FROM cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, 'car', ARRAY[300,900,12000]::integer[]); +INSERT INTO {table} (the_geom) SELECT the_geom FROM cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, 'car', ARRAY[300, 900, 12000]::integer[], ARRAY['mode_traffic=enabled','quality=3']::text[]) ``` +or equivalently: + ```bash -SELECT * FROM cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300,900]::integer[], ARRAY['mode_traffic=enabled','quality=3']::text[]); +INSERT INTO {table} (the_geom) SELECT (cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, 'car', ARRAY[300, 900, 12000]::integer[], ARRAY['mode_traffic=enabled','quality=3']::text[])).the_geom ``` -##### Select the geometric results of the isochrone function - -```bash -SELECT the_geom FROM cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, 'walk', ARRAY[300]::integer[]); -``` - -##### Calculate and insert the generated isolines from `points_table` table to another table +##### Calculate and insert the generated isolines from `points_table` table into another table ```bash INSERT INTO {table} (the_geom) SELECT (cdb_isochrone(the_geom, 'walk', string_to_array(time_distance, ',')::integer[])).the_geom FROM {points_table} From 5ea0d0e6daeef8dd7de1ff1f0da55cf2fc59ff26 Mon Sep 17 00:00:00 2001 From: Carla Iriberri Date: Wed, 4 May 2016 19:54:11 +0200 Subject: [PATCH 5/8] Remove comment related to admin0 geocoding --- doc/isoline_functions.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/doc/isoline_functions.md b/doc/isoline_functions.md index d1f4f08..8128e5a 100644 --- a/doc/isoline_functions.md +++ b/doc/isoline_functions.md @@ -11,12 +11,6 @@ polygon({country_column})&api_key={api_key} https://{username}.cartodb.com/api/v2/sql?q=SELECT cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, 'car', ARRAY[300,600,900]::integer[])&api_key={api_key} ``` -Notice that you can make use of Postgres or PostGIS functions in your Data Services API requests, as the result is a geometry that can be handled by the system. For example, suppose you need to retrieve the centroid of a specific country, you can wrap the resulting geometry from the geocoder functions inside the PostGIS `ST_Centroid` function: - -```bash -https://{username}.cartodb.com/api/v2/sql?q=SELECT ST_Centroid(cdb_geocode_admin0_polygon('USA'))&api_key={api_key} -``` - The following functions provide an isoline generator service, based on time or distance. This service uses the isolines service defined for your account. The default service limits the usage of displayed polygons represented on top of [HERE](https://developer.here.com/coverage-info) maps. ## cdb_isodistance(_source geometry, mode text, range integer[], [options text[]]_) From fdc58f1eb0a282a080dc71f7f54e5007131158e7 Mon Sep 17 00:00:00 2001 From: Carla Iriberri Date: Wed, 4 May 2016 20:00:04 +0200 Subject: [PATCH 6/8] Remove selects from geocoding functions --- doc/geocoding_functions.md | 125 ++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 57 deletions(-) diff --git a/doc/geocoding_functions.md b/doc/geocoding_functions.md index d7f5dcc..7e70c38 100644 --- a/doc/geocoding_functions.md +++ b/doc/geocoding_functions.md @@ -16,6 +16,13 @@ In order to geocode an existent CartoDB dataset, an SQL UPDATE statement must be https://{username}.cartodb.com/api/v2/sql?q=UPDATE {tablename} SET the_geom = cdb_geocode_admin0_ ``` +Notice that you can make use of Postgres or PostGIS functions in your Data Services API requests, as the result is a geometry that can be handled by the system. For example, suppose you need to retrieve the centroid of a specific country, you can wrap the resulting geometry from the geocoder functions inside the PostGIS `ST_Centroid` function: + +```bash +https://{username}.cartodb.com/api/v2/sql?q=UPDATE {tablename} SET the_geom = ST_Centroid(cdb_geocode_admin0_polygon('USA'))&api_key={api_key} +``` + + The following geocoding functions are available, grouped by categories. ## Country Geocoder @@ -38,18 +45,17 @@ Geometry (polygon, EPSG 4326) or null #### Example -##### Select - -```bash -SELECT cdb_geocode_admin0_polygon('France') -``` - -##### Update +##### Update the geometry of a table to geocode it ```bash UPDATE {tablename} SET the_geom = cdb_geocode_admin0_polygon({country_column}) ``` +##### Insert a geocoded row into a table + +```bash +UPDATE {tablename} SET the_geom = cdb_geocode_admin0_polygon('France') +``` ## Level-1 Administrative Regions Geocoder @@ -71,18 +77,19 @@ Geometry (polygon, EPSG 4326) or null #### Example -##### Select - -```bash -SELECT cdb_geocode_admin1_polygon('Alicante') -``` - -##### Update +##### Update the geometry of a table to geocode it ```bash UPDATE {tablename} SET the_geom = cdb_geocode_admin1_polygon({province_column}) ``` +##### Insert a geocoded row into a table + +```bash +UPDATE {tablename} SET the_geom = cdb_geocode_admin1_polygon('Alicante') +``` + + ### cdb_geocode_admin1_polygon(_admin1_name text, country_name text_) Geocodes the name of the province/state for a specified country into a Level-1 administrative region, displayed as a polygon geometry. @@ -100,17 +107,16 @@ Geometry (polygon, EPSG 4326) or null #### Example -##### Select - -```bash -SELECT cdb_geocode_admin1_polygon('Alicante', 'Spain') -``` - -##### Update +##### Update the geometry of a table to geocode it ```bash UPDATE {tablename} SET the_geom = cdb_geocode_admin1_polygon({province_column}, {country_column}) ``` +##### Insert a geocoded row into a table + +```bash +UPDATE {tablename} SET the_geom = cdb_geocode_admin1_polygon('Alicante', 'Spain') +``` ## City Geocoder @@ -135,16 +141,19 @@ Geometry (point, EPSG 4326) or null ##### Select -```bash -SELECT cdb_geocode_namedplace_point('Barcelona') -``` - -##### Update +##### Update the geometry of a table to geocode it ```bash UPDATE {tablename} SET the_geom = cdb_geocode_namedplace_point({city_column}) ``` +##### Insert a geocoded row into a table + +```bash +UPDATE {tablename} SET the_geom = cdb_geocode_namedplace_point('Barcelona') +``` + + ### cdb_geocode_namedplace_point(_city_name text, country_name text_) Geocodes the text name of a city for a specified country into a named place point geometry. @@ -162,18 +171,19 @@ Geometry (point, EPSG 4326) or null #### Example -##### Select - -```bash -SELECT cdb_geocode_namedplace_point('Barcelona', 'Spain') -``` - -##### Update +##### Update the geometry of a table to geocode it ```bash UPDATE {tablename} SET the_geom = cdb_geocode_namedplace_point({city_column}, 'Spain') ``` +##### Insert a geocoded row into a table + +```bash +UPDATE {tablename} SET the_geom = cdb_geocode_namedplace_point('Barcelona', 'Spain') +``` + + ### cdb_geocode_namedplace_point(_city_name text, admin1_name text, country_name text_) Geocodes your data into a named place point geometry, containing the text name of a city, for a specified province/state and country. This is recommended for the most accurate geocoding of city data. @@ -191,18 +201,18 @@ Geometry (point, EPSG 4326) or null #### Example -##### Select - -```bash -SELECT cdb_geocode_namedplace_point('New York', 'New York', 'USA') -``` - -##### Update +##### Update the geometry of a table to geocode it ```bash UPDATE {tablename} SET the_geom = cdb_geocode_namedplace_point({city_column}, {province_column}, 'USA') ``` +##### Insert a geocoded row into a table + +```bash +UPDATE {tablename} SET the_geom = cdb_geocode_namedplace_point('New York', 'New York', 'USA') +``` + ## Postal Code Geocoder This function geocodes your data into point, or polygon, geometries for postal codes. The postal code polygon geocoder covers the United States, France, Australia and Canada; a request for a different country will return an empty response. @@ -226,18 +236,18 @@ Geometry (polygon, EPSG 4326) or null #### Example -##### Select - -```bash -SELECT cdb_geocode_postalcode_polygon('11211', 'USA') -``` - -##### Update +##### Update the geometry of a table to geocode it ```bash UPDATE {tablename} SET the_geom = cdb_geocode_postalcode_polygon({postal_code_column}, 'USA') ``` +##### Insert a geocoded row into a table + +```bash +UPDATE {tablename} SET the_geom = cdb_geocode_postalcode_polygon('11211', 'USA') +``` + ### cdb_geocode_postalcode_point(_code text, country_name text_) Goecodes the postal code for a specified country into a **point** geometry. @@ -255,18 +265,19 @@ Geometry (point, EPSG 4326) or null #### Example -##### Select - -```bash -SELECT cdb_geocode_postalcode_point('11211', 'USA') -``` - -##### Update +##### Update the geometry of a table to geocode it ```bash UPDATE {tablename} SET the_geom = cdb_geocode_postalcode_point({postal_code_column}, 'USA') ``` +##### Insert a geocoded row into a table + +```bash +UPDATE {tablename} SET the_geom = cdb_geocode_postalcode_point('11211', 'USA') +``` + + ## IP Addresses Geocoder This function geocodes your data into point geometries for IP addresses. This is useful if you are analyzing location based data, based on a set of user's IP addresses. @@ -288,13 +299,13 @@ Geometry (point, EPSG 4326) or null #### Example -##### Select +##### Update the geometry of a table to geocode it ```bash -SELECT cdb_geocode_ipaddress_point('102.23.34.1') +UPDATE {tablename} SET the_geom = cdb_geocode_ipaddress_point('102.23.34.1') ``` -##### Update +##### Insert a geocoded row into a table ```bash UPDATE {tablename} SET the_geom = cdb_geocode_ipaddress_point('102.23.34.1') From 9b88e91ec296d80629c06f0dc75f8c44d5d110da Mon Sep 17 00:00:00 2001 From: Carla Iriberri Date: Wed, 4 May 2016 20:01:37 +0200 Subject: [PATCH 7/8] remove a select example --- doc/isoline_functions.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/isoline_functions.md b/doc/isoline_functions.md index 8128e5a..0c54efb 100644 --- a/doc/isoline_functions.md +++ b/doc/isoline_functions.md @@ -4,11 +4,10 @@ _**This service is subject to quota limitations and extra fees may apply**. View the [Quota Information](http://docs.cartodb.com/cartodb-platform/dataservices-api/quota-information/) section for details and recommendations about to quota consumption._ -You can use the isoline functions to retrieve, for example, isochrone lines from a certain location, specifying the mode and the ranges that will define each of the isolines. The following query calculates isolines for areas that are 5, 10 and 15 minutes (300, 600 and 900 seconds, respectively) away from the location by following a path defined by car routing. -polygon({country_column})&api_key={api_key} +You can use the isoline functions to retrieve, for example, isochrone lines from a certain location, specifying the mode and the ranges that will define each of the isolines. The following query calculates isolines for areas that are 5, 10 and 15 minutes (300, 600 and 900 seconds, respectively) away from the location by following a path defined by car routing and inserts them into a table. ```bash -https://{username}.cartodb.com/api/v2/sql?q=SELECT cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, 'car', ARRAY[300,600,900]::integer[])&api_key={api_key} +https://{username}.cartodb.com/api/v2/sql?q=INSERT INTO {table} (the_geom) SELECT the_geom FROM cdb_isodistance('POINT(-3.70568 40.42028)'::geometry, 'car', ARRAY[300, 600, 900]::integer[])&api_key={api_key} ``` The following functions provide an isoline generator service, based on time or distance. This service uses the isolines service defined for your account. The default service limits the usage of displayed polygons represented on top of [HERE](https://developer.here.com/coverage-info) maps. From 01a3fa3b59bc0fdc385ee396e1249b5191a0b607 Mon Sep 17 00:00:00 2001 From: Carla Iriberri Date: Wed, 4 May 2016 20:06:37 +0200 Subject: [PATCH 8/8] Corrected error in insertinto statements --- doc/geocoding_functions.md | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/doc/geocoding_functions.md b/doc/geocoding_functions.md index 7e70c38..232d0ea 100644 --- a/doc/geocoding_functions.md +++ b/doc/geocoding_functions.md @@ -54,7 +54,7 @@ UPDATE {tablename} SET the_geom = cdb_geocode_admin0_polygon({country_column}) ##### Insert a geocoded row into a table ```bash -UPDATE {tablename} SET the_geom = cdb_geocode_admin0_polygon('France') +INSERT INTO {tablename} (the_geom) SELECT cdb_geocode_admin0_polygon('France') ``` ## Level-1 Administrative Regions Geocoder @@ -86,7 +86,7 @@ UPDATE {tablename} SET the_geom = cdb_geocode_admin1_polygon({province_column}) ##### Insert a geocoded row into a table ```bash -UPDATE {tablename} SET the_geom = cdb_geocode_admin1_polygon('Alicante') +INSERT INTO {tablename} (the_geom) SELECT cdb_geocode_admin1_polygon('Alicante') ``` @@ -115,7 +115,7 @@ UPDATE {tablename} SET the_geom = cdb_geocode_admin1_polygon({province_column}, ##### Insert a geocoded row into a table ```bash -UPDATE {tablename} SET the_geom = cdb_geocode_admin1_polygon('Alicante', 'Spain') +INSERT INTO {tablename} (the_geom) SELECT cdb_geocode_admin1_polygon('Alicante', 'Spain') ``` @@ -150,7 +150,7 @@ UPDATE {tablename} SET the_geom = cdb_geocode_namedplace_point({city_column}) ##### Insert a geocoded row into a table ```bash -UPDATE {tablename} SET the_geom = cdb_geocode_namedplace_point('Barcelona') +INSERT INTO {tablename} (the_geom) SELECT cdb_geocode_namedplace_point('Barcelona') ``` @@ -180,7 +180,7 @@ UPDATE {tablename} SET the_geom = cdb_geocode_namedplace_point({city_column}, 'S ##### Insert a geocoded row into a table ```bash -UPDATE {tablename} SET the_geom = cdb_geocode_namedplace_point('Barcelona', 'Spain') +INSERT INTO {tablename} (the_geom) SELECT cdb_geocode_namedplace_point('Barcelona', 'Spain') ``` @@ -210,7 +210,7 @@ UPDATE {tablename} SET the_geom = cdb_geocode_namedplace_point({city_column}, {p ##### Insert a geocoded row into a table ```bash -UPDATE {tablename} SET the_geom = cdb_geocode_namedplace_point('New York', 'New York', 'USA') +INSERT INTO {tablename} (the_geom) SELECT cdb_geocode_namedplace_point('New York', 'New York', 'USA') ``` ## Postal Code Geocoder @@ -245,7 +245,7 @@ UPDATE {tablename} SET the_geom = cdb_geocode_postalcode_polygon({postal_code_co ##### Insert a geocoded row into a table ```bash -UPDATE {tablename} SET the_geom = cdb_geocode_postalcode_polygon('11211', 'USA') +INSERT INTO {tablename} (the_geom) SELECT cdb_geocode_postalcode_polygon('11211', 'USA') ``` ### cdb_geocode_postalcode_point(_code text, country_name text_) @@ -274,7 +274,7 @@ UPDATE {tablename} SET the_geom = cdb_geocode_postalcode_point({postal_code_colu ##### Insert a geocoded row into a table ```bash -UPDATE {tablename} SET the_geom = cdb_geocode_postalcode_point('11211', 'USA') +INSERT INTO {tablename} (the_geom) SELECT cdb_geocode_postalcode_point('11211', 'USA') ``` @@ -308,7 +308,7 @@ UPDATE {tablename} SET the_geom = cdb_geocode_ipaddress_point('102.23.34.1') ##### Insert a geocoded row into a table ```bash -UPDATE {tablename} SET the_geom = cdb_geocode_ipaddress_point('102.23.34.1') +INSERT INTO {tablename} (the_geom) SELECT cdb_geocode_ipaddress_point('102.23.34.1') ``` ## Street-Level Geocoder @@ -336,19 +336,14 @@ Geometry (point, EPSG 4326) or null #### Example -##### Select - -Using SELECT for geocoding functions - -```bash -SELECT cdb_geocode_street_point('651 Lombard Street, San Francisco, California, United States') -SELECT cdb_geocode_street_point('651 Lombard Street', 'San Francisco') -SELECT cdb_geocode_street_point('651 Lombard Street', 'San Francisco', 'California') -SELECT cdb_geocode_street_point('651 Lombard Street', 'San Francisco', 'California', 'United States') -``` - -##### Update +##### Update the geometry of a table to geocode it ```bash UPDATE {tablename} SET the_geom = cdb_geocode_street_point({street_name_column}) ``` + +##### Insert a geocoded row into a table + +```bash +INSERT INTO {tablename} (the_geom) SELECT cdb_geocode_street_point('651 Lombard Street', 'San Francisco', 'California', 'United States') +```