Find addresses and places with the ArcGIS World Geocoding Service.
Overview
You will learn: how to find addresses and places with the ArcGIS World Geocoding Service.
The ArcGIS World Geocoding Service can find addresses, places, convert addresses to coordinates, and perform batch geocoding. If you would like to create an application that can find the coordinates (latitude and longitude) for one or more addresses, you can use the ArcGIS REST API to call the findAddressCandidates operation. All you need to do is pass in an address e.g. "380 New York St., Redlands, CA" and the service will return a set of candidates. Once you have candidates, you can add them to a map, create a route, or integrate them further into your application. You can also geocode many addresses at once with the geocodeAddresses operation. To learn more about the capabilities of the geocoding service, please visit the documentation.
Add parameters to define the address and data fields to return
Click on Params next to the URL and the following:
f: json
singleLine: 4730 Crystal Springs Dr, Los Angeles, CA 90027
outFields: Match_addr,Addr_type
Execute the request to geocode the address and get the coordinate candidates
Click Send to run the request.
In the response window, click Pretty > JSON and it should look something like this:
{"spatialReference":{"wkid":4326,"latestWkid":4326},"candidates":[{"address":"4730 Crystal Springs Dr, Los Angeles, California, 90027","location":{"x":-118.27393677823306,"y":34.123473000000004},"score":100,"attributes":{"Match_addr":"4730 Crystal Springs Dr, Los Angeles, California, 90027","Addr_type":"PointAddress"},"extent":{"xmin":-118.27486,"ymin":34.122473000000006,"xmax":-118.27285999999999,"ymax":34.124473000000002}},{"address":"4730 Crystal Springs Rd, Los Angeles, California, 90027","location":{"x":-118.29234632205821,"y":34.140621986664307},"score":98.040000000000006,"attributes":{"Match_addr":"4730 Crystal Springs Rd, Los Angeles, California, 90027","Addr_type":"StreetAddress"},"extent":{"xmin":-118.29334632205821,"ymin":34.139621986664309,"xmax":-118.2913463220582,"ymax":34.141621986664305}}]}
Go to the top of the response and find the spatialReference and candidates properties. The spatialReference is 4326 and tells you that the coordinates given in candidates will be latitude/longitude coordinates (y/x). This is the default spatial reference.
Find the candidates property. This is an array of possible matches for the address. Each match consists of:
address: The address of this match.
location: The x/y coordinates of this match. Note that x is longitude and y is latitude.
score: The confidence level of the geocoder in this match, on a scale of 1-100.
attributes: Any additional fields requested by the outFields parameter.
extent: a rectangular bounding box around the location given as a pair of x/y coordinates.
"candidates":[{"address":"4730 Crystal Springs Dr, Los Angeles, California, 90027","location":{"x":-118.27393677823306,"y":34.123473000000004},"score":100,"attributes":{"Match_addr":"4730 Crystal Springs Dr, Los Angeles, California, 90027","Addr_type":"PointAddress"},"extent":{"xmin":-118.27486,"ymin":34.122473000000006,"xmax":-118.27285999999999,"ymax":34.124473000000002}},
...
In Postman click Code below the Send button. Select a programming language and use Postman to generate sample code for your application to run this request.
Congratulations, you're done!
You have successfully found a set of candidates with coordinates for an address.
Challenge
Use geocoding suggestions
You can use the Esri World Geocoding Service to build an auto-completing, suggestion-based UX by adding a special parameter called magicKey to findAddressCandidates instead of an address. To obtain a value for magicKey, refer to the documentation for the suggest endpoint.
Try bulk geocoding
If you need to geocode many addresses in bulk, you can use the geocode addresses endpoint.
Find latitude/longitude of intersections
findAddressCandidates can also return the coordinates of intersections if the address is in the proper format. For more information, see searching for intersections and try changing the value of singleLine to "Grasswood Ave & Cliffside Dr, Malibu, CA, 90265, USA"
Next
Find places
Search for coffee shops, gas stations, restaurants, and other nearby places with the ArcGIS World Geocoding Service.
To successfully use the ArcGIS REST API, you must understand how to construct a URL and interpret the response. All resources and operations exposed by the ArcGIS Services portion of the REST API are accessible through a hierarchy of endpoints for each GIS service published with ArcGIS Server.
Determine the well-known endpoint
When using the REST API, you must know the well-known endpoint, which represents a server catalog.
For ArcGIS Server, the default endpoint is as follows:
/<site> is the site name. The default value is "/arcgis/". ArcGIS Server accepts a site name specified in a URL as lowercase (arcgis) or camel case (ArcGIS). Using an all lowercase site name is recommended.
rest/services indicates the REST services endpoint. You'll see a list of all services in the root directory along with any folders. This part of the URL is case sensitive and should be specified in all lowercase.
/<folder> lists all services included in this folder. Folder names are case sensitive and should be specified in the case in which it was created.
/<serviceName>/<serviceType> represents the name of the service and its type (for example, PopulationDensity/MapServer). The service name is case sensitive and should be specified in the case in which it was created. The service type should always be specified in a mixed case format as defined for each service in the REST API reference (for example, MapServer, GeocodeServer, and GPServer).
For example, to get to the root directory of Sample Server 1 on ArcGIS Online services, the URL is as follows:
When using the REST API, you need to construct URLs. The Services Directory can help you generate URLs that include the reference to a resource as well as any parameters. A URL with parameters will have the following syntax:
https://<resource-url> is the URL to a given resource. If the resource is a server object extension or a geoprocessing service task, the resource name is case sensitive.
<Operation> represents the name of an operation supported on a resource. The operation name is not case sensitive, but it's recommended that you use the operation name as specified in the REST API.
? denotes the beginning of a parameter list.
parameter1=value1 is a name-value pair. The parameter values are case sensitive if the value is JSON or enumeration.
Almost all resources have an f parameter. This parameter determines the output format. For more information, see Output formats.
To retrieve information about a map service in a JSON object, you would use a URL similar to the following:
In another example, you can request to export a map. In this case, you would use the map service export operation. For this operation, you need to include the bbox parameter. Some parameters are optional and some are required. These requirements are noted in the documentation. An example URL is as follows:
The above URL returns the response in HTML format, and you see an image along with its width, height, extent, and scale. If you want the same information returned in a JSON object, you need to include the fparameter:
If you want the JSON object response to be more readable, you can use pjson. This option should only be used for debugging purposes, since it takes longer to process the response.
Use the Services Directory dialog boxes to generate parameter values in the URL
The Services Directory includes dialog boxes for all valid operations with a resource. These dialog boxes allow you to input values for URL parameters for testing purposes. The response includes the results and an encoded URL.
As an example, view the find dialog box for a USA service on sampleserver1:
A second option, when using certain geometry service and geoprocessing service operations, is to continue to use GET and to specify a URL to the input JSON object contained in a file on a public server.
When making a POST request to an operation that involves uploading a file, such as addAttachment for feature services, specify the content type as multipart/form-data. For all other POST requests, specify the content type as application/x-www-form-urlencoded.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
2019-10-12 基于OpenCV/TensorFlow的手写MNIST文字匹配
2019-10-12 随机游走 点云匹配
2018-10-12 一种基于图像特征的图像相似性评价