0% found this document useful (0 votes)
78 views3 pages

Geocoding and Reverse Geocoding Explained

Geocoding is the process of converting human-readable addresses into geographic coordinates (latitude and longitude), while reverse geocoding converts geographic coordinates back into human-readable addresses. Both processes utilize a Geocoder class in APIs to handle the conversions, with specific methods for retrieving addresses based on coordinates and vice versa. The results of reverse geocoding may not guarantee a place name, but will provide a complete address based on the given coordinates.

Uploaded by

Shravani Lad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views3 pages

Geocoding and Reverse Geocoding Explained

Geocoding is the process of converting human-readable addresses into geographic coordinates (latitude and longitude), while reverse geocoding converts geographic coordinates back into human-readable addresses. Both processes utilize a Geocoder class in APIs to handle the conversions, with specific methods for retrieving addresses based on coordinates and vice versa. The results of reverse geocoding may not guarantee a place name, but will provide a complete address based on the given coordinates.

Uploaded by

Shravani Lad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

 Explain Geocoding and reverse geocoding.

(4M)
- Geocoding converts addresses into geographic coordinates (latitude and longitude).
- Reverse geocoding does the opposite, it converts coordinates into human-readable
addresses.
-
Geocoding:
 Input:
A human-readable address (e.g., "1600 Amphitheatre Parkway, Mountain View, CA").
 Process:
Uses a geocoding service or API to find the corresponding geographic coordinates (e.g.,
latitude and longitude) for the given address.
 Output:
Geographic coordinates (e.g., latitude: 37.423021, longitude: -122.083739).

Reverse Geocoding:
 Input:
Geographic coordinates (e.g., latitude: 37.423021, longitude: -122.083739).
 Process:
Uses a geocoding service or API to find the nearest human-readable address or place name
for the given coordinates.
 Output:
A human-readable address (e.g., "1600 Amphitheatre Parkway, Mountain View, CA").

- Reverse-Geocoding is a process used to convert coordinates (latitude and longitude) to human


readable addresses.
- This is not exactly the opposite of Geocoding.
- In Geocoding, the place is associated with a name and fixed coordinates.
- These coordinates are double in nature.
- Negligible change in these coordinates may still refer to the same place, but we shall never get
the place name as it is associated with only those fixed coordinates.
- Therefore, we shall definitely get the complete address in reverse geocoding, but the place name
is not guaranteed.
- Searching location in Google Map API is done through Geocoder class. Geocoder class is used to
handle geocoding and reverse geocoding.
- Geocoding is a process in which street address is converted into a coordinate (latitude,longitude).
Reverse geocoding is a process in which a coordinate (latitude,longitude) is converted into an
address.
Methods of Geocoder class
- List<Address> getFromLocation(double latitude, double longitude, int
maxResults): This method returns an array of Address which specifies the
surrounding latitude and longitude.
- List<Address> getFromLocationName(String location, int results, double
leftLatitude, double leftLongitude, double rightLatitude, double
rightLongitude): This method returns an array of Address which describes the given
location such as place, an address, etc.
- List<Address> getFromLocationName(String location, int results): This method
returns an array of Address which describes te given location such as place, an
address, etc.
- static boolean isPresent(): This method returns true if the methods
getFromLocation() and getFromLocationName() are implemented.

Code which convert location name into coordinate.


List<Address> addressList = [Link](location, 1);
Address address = [Link](0);
LatLng latLng = new LatLng([Link](), [Link]());

Geocoding
Geocoder geocoder = new Geocoder(context);
try {
List<Address> addresses = [Link](address, 1); // Get up
to 1 result
if (addresses != null && ![Link]()) {
Address foundAddress = [Link](0);
double latitude = [Link]();
double longitude = [Link]();
[Link](getApplicationContext(),"Latitude: " + latitude + ", Longitude: "
+ longitude,Toast.LENGTH_LONG).show();
}
else
{
[Link](getApplicationContext(),Toast.LENGTH_LONG).show();
}
} catch (IOException e) { }

Reverse Geocoding
Geocoder geocoder = new Geocoder(context);
long latitude=1430000;
long longitude=145000;

try {
List<Address> addresses = [Link](latitude, longitude, 1); //
Get up to 1 result
if (addresses != null && ![Link]()) {
Address foundAddress = [Link](0);
[Link](getApplicationContect(),"Address: " +
[Link](0),Toast.LENGTH_LONG).show();
} else {
[Link](getApplicationContect(),"No address found.",
Toast.LENGTH_LONG).show();
}
} catch (IOException e) { }

You might also like