Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/workers
Class: GeographyQuery

require(["esri/tasks/geoenrichment/GeographyQuery"], function(GeographyQuery) { /* code goes here */ });

Description

(Added at v3.12)
(Currently in beta)
Represents StandardGeographyQuery parameters to search for geographies by ID or Name.

Samples

Search for samples that use this class.

Class hierarchy

esri/tasks/geoenrichment/GeographyQueryBase
|_esri/tasks/geoenrichment/GeographyQuery

Constructors

NameSummary
new GeographyQuery()Creates a new instance of the GeographyQuery object.

Properties

NameTypeSummary
countryIDStringTwo-digit country code.
datasetIDStringOptional string that denotes the ID of a dataset associated with a particular country.
featureLimitNumberOptional integer value where you can limit the number of features that are returned from the geographyQuery.
generalizationLevelNumberOptional integer that specifies the level of generalization of the geometries.
geographyIDsString[]Array of geography IDs.
geographyLayerIDsString[]Array of geography layer IDs.
outSRSpatialReferenceDetermines spatial reference for output geometry if returnGeometry is set to true.
returnCentroidsBooleanUse this parameter to return all the geometries as points.
returnGeometryBooleanDetermines whether response will also include geometries.
useFuzzySearchBooleanOptional boolean to enable fuzzy search.
whereStringA where clause for the query.

Methods

NameReturn typeSummary
toJson()ObjectConverts object to its JSON representation.
Constructor Details

new GeographyQuery()

Creates a new instance of the GeographyQuery object.
Sample:
Query for zip codes in San Diego
require([
  "esri/tasks/geoenrichment/GeographyQuery", ...
], function(GeographyQuery, ...) {
  var query = new GeographyQuery({
    countryID: "US",
    datasetID: "USA_ESRI_2013",
    generalizationLevel: "6",
    geographyIDs: ["92129", "92126"],
    geographyLayerIDs: ["US.ZIP5"],
    returnGeometry: "true"
  });
  ...
});
Query for cities and counties in the US that contain "San" in their name
require([
  "esri/tasks/geoenrichment/GeographyQuery", ...
], function(GeographyQuery, ...) {
  var query = new GeographyQuery({
    countryID: "US",
    datasetID: "USA_ESRI_2013",
    generalizationLevel: "6",
    geographyLayerIDs: ["US.Counties", "US.Places"],
    returnGeometry: "true",
    returnCentroids: "true",
    where: "San"
  });
  ...
});
Query for all municipalities in France
require([
  "esri/tasks/geoenrichment/GeographyQuery", ...
], function(GeographyQuery, ...) {
  var query = new GeographyQuery({
    countryID: "FR",
    datasetID: "FRANCE",
    generalizationLevel: "6",
    geographyLayerIDs: ["FR.Commune"],
    returnGeometry: "true"
  });
  ...
});
Property Details

<String> countryID

Two-digit country code. For example: "US".

<String> datasetID

Optional string that denotes the ID of a dataset associated with a particular country.
Sample:
query.datasetID = 'US.Census2010';

<Number> featureLimit

Optional integer value where you can limit the number of features that are returned from the geographyQuery. If null, the server will default to 1000.

<Number> generalizationLevel

Optional integer that specifies the level of generalization of the geometries. A value of 0 returns the most detailed and 6 is most generalized. Some geography layers, like 'countries', do not support returning highly detailed geometries.
Known values: 0|1|2|3|4|5|6
Default value: 0

<String[]> geographyIDs

Array of geography IDs. Use this property to return attributes and/or geometries for standard geographic areas for administrative areas where you already know the ID, for example, if you know the Federal Information Processing Standard (FIPS) Codes for a U.S. state or county; or, in Canada, to return the geometry and attributes for a Forward Sortation Area (FSA). Note: only returns features from layers specified in the geographyLayerIDs property.

<String[]> geographyLayerIDs

Array of geography layer IDs.
Determines spatial reference for output geometry if returnGeometry is set to true.

<Boolean> returnCentroids

Use this parameter to return all the geometries as points. For example, you could return all U.S. ZIP Codes as centroids. Only applies if the returnGeometry property is also set to true.
Known values: true | false
Default value: false

<Boolean> returnGeometry

Determines whether response will also include geometries.
Known values: true | false
Default value: false

<Boolean> useFuzzySearch

Optional boolean to enable fuzzy search. See the REST API for details about using fuzzy logic.
Known values: true | false
Default value: false

<String> where

A where clause for the query. Use this property to query for specific areas, for example, all U.S. counties that contain the word "orange".

Optionally, you can specify to search by ID or by Name, for example: query.where = 'ID:06069' or query.where = 'NAME:"Orange County"'.

    Notes
  • Use the geographyLayerIDs property to define which layers are being searched. To achieve optimal performance, it is strongly recommended that at least one layer is defined in the geographyLayerIDs property. If no geographyLayerIDs are provided, all standard geography layers will be searched within sourceCountry. This will adversely affect performance.
  • If the useFuzzySearch property is set to true, all words submitted with geographyQuery will be searched with fuzzy logic. If it is set to false, a standard text search is performed for all text submitted.
  • Searches within the geography query are not case sensitive.
See Standard geograpy query REST API for more details on the query syntax.
Method Details

toJson()

Converts object to its JSON representation. Field names in the JSON will match field names used by the REST API.
Return type: Object