如何将地址转换为纬度/经度?

发布于 2024-07-04 16:15:25 字数 85 浏览 10 评论 0原文

我如何将地址或城市转换为纬度/经度? 我可以从哪些商业机构“租用”这项服务? 这将用于具有全时互联网访问的 Windows PC 上的商业桌面应用程序。

How would I go about converting an address or city to a latitude/longitude? Are there commercial outfits I can "rent" this service from? This would be used in a commercial desktop application on a Windows PC with fulltime internet access.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(18

短暂陪伴 2024-07-11 16:15:26

当您将地址或对象转换为纬度/经度时,称为地理编码。

周围有很多地理编码解决方案。 适合您项目的解决方案将取决于每个地理编码解决方案的许可条款的可接受性。 Microsoft Virtual Earth 和 Google Maps 都提供了在非常严格的许可下免费使用的解决方案...

https://developers.google.com/maps/documentation/javascript/tutorial

When you convert an address or object to a lat/long it is called Geocoding.

There are a lot geocoding solutions around. The solution right for your project will depend on the acceptability of the licensing terms of each geocoding solution. Both Microsoft Virtual Earth and Google Maps offer solutions which are free to use under a very restrictive licenses...

https://developers.google.com/maps/documentation/javascript/tutorial

笔芯 2024-07-11 16:15:26

之前已经为此推出了自己的解决方案,我可以全心全意地推荐 Geo::Coder ::US Perl 模块用于此目的。 只需下载所有人口普查数据并使用附带的导入程序为您的国家/地区创建 Berkeley DB 并将 Perl 脚本指向它即可。 使用模块的内置地址解析,您就拥有了:离线地理编码系统!

Having rolled my own solution for this before, I can whole heartedly recommend the Geo::Coder::US Perl module for this. Just download all the census data and use the included importer to create the Berkeley DB for your country and point the Perl script at it. Use the module's built in address parsing, and there you have it: An offline geocoding system!

不可一世的女人 2024-07-11 16:15:26

尝试使用此代码,我像这样处理地址:

它是一个链接,您将使用 GET 方法发送请求并获取纬度和经度。 http://maps.google.com/maps/api/geocode/json ?address=您的地址&sensor=false

例如: http://maps.google.com/maps/api/geocode/json?address=W Main St, Bergenfield, NJ 07621& ;传感器=假

1。 创建您的 GET 方法。

 public static String GET(String url) throws Exception {//GET Method
        String result = null;
        InputStream inputStream = null;
        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpGet httpGet = new HttpGet(url);

        Log.v("ExecuteGET: ", httpGet.getRequestLine().toString());

        HttpResponse httpResponse = httpclient.execute(httpGet);
        inputStream = httpResponse.getEntity().getContent();
        if (inputStream != null) {
            result = convertInputStreamToString(inputStream);
            Log.v("Result: ", "result\n" + result);
        } 
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}

2. 创建发送请求的方法

@SuppressWarnings("deprecation")
    public static String getLatLng(String accessToken) throws Exception{
        String query=StaticString.gLobalGoogleUrl+"json?address="+URLEncoder.encode(accessToken)+"&sensor=false";
        Log.v("GETGoogleGeocoder", query+"");
        return GET(query);
    }

gLobalGoogleUrl="http://maps.google.com/maps/api/geocode/"

3. 调用方法getLatLng

String result=getLatLng("W Main St, Bergenfield, NJ 07621");

4. 解析 JSONObject

现在结果JSONObject,其中包含有关地址和 lan、lng 的信息。
使用 gson() 解析 JSONObject(结果)。
之后使用纬度,经度。

如果您对代码有疑问,请询问。

Try with this code, i work like this with addresses:

It is link in which with GET method you will send request and get lat and lng. http://maps.google.com/maps/api/geocode/json?address=YOUR ADDRES&sensor=false

For exemple: http://maps.google.com/maps/api/geocode/json?address=W Main St, Bergenfield, NJ 07621&sensor=false

1. Create your GET method.

 public static String GET(String url) throws Exception {//GET Method
        String result = null;
        InputStream inputStream = null;
        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpGet httpGet = new HttpGet(url);

        Log.v("ExecuteGET: ", httpGet.getRequestLine().toString());

        HttpResponse httpResponse = httpclient.execute(httpGet);
        inputStream = httpResponse.getEntity().getContent();
        if (inputStream != null) {
            result = convertInputStreamToString(inputStream);
            Log.v("Result: ", "result\n" + result);
        } 
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}

2. Create method for send request

@SuppressWarnings("deprecation")
    public static String getLatLng(String accessToken) throws Exception{
        String query=StaticString.gLobalGoogleUrl+"json?address="+URLEncoder.encode(accessToken)+"&sensor=false";
        Log.v("GETGoogleGeocoder", query+"");
        return GET(query);
    }

gLobalGoogleUrl="http://maps.google.com/maps/api/geocode/"

3. Call method getLatLng

String result=getLatLng("W Main St, Bergenfield, NJ 07621");

4. Parse JSONObject

Now result is JSONObject with information about address and lan,lng.
Parse JSONObject (result) with gson().
After that use lat,lng.

If you have question about code , ask.

生寂 2024-07-11 16:15:26

您需要一个地理编码应用程序。 这些可以在线使用或作为应用程序后端使用。

You want a geocoding application. These are available either online or as an application backend.

新人笑 2024-07-11 16:15:26

Maptsraction (http://www.mapstraction.com) 可让您在任意数量的地理编码服务之间进行选择。 如果你需要做大量的事情,这可能会很有帮助,因为我知道谷歌对你每天可以做的数量有限制。

Maptsraction (http://www.mapstraction.com) lets you choose between any number of geocoding services. This could be helpful if you need to do large quantities, as I know Google has a limit to how many you can do a day.

贱贱哒 2024-07-11 16:15:26

虚拟地球做到了。 geocoder.us 上还有一个网络服务

Virtual Earth does it. There is also a web service at geocoder.us

似梦非梦 2024-07-11 16:15:26

您还可以尝试 OpenStreetMap NameFinder(或当前的 Nominatim),其中包含(可能)整个世界的开源、类似维基的街道数据。

You could also try the OpenStreetMap NameFinder (or the current Nominatim), which contains open source, wiki-like street data for (potentially) the entire world.

扛刀软妹 2024-07-11 16:15:26

您可以使用 bing 地图肥皂服务,您可以在其中引用反向地理编码服务以从地址查找纬度/经度
链接在这里
http://msdn.microsoft.com/en-us/library/cc980922.aspx

you can use bing maps soap services, where you can reference reverse geocode service to find lat/long from address
here is the link
http://msdn.microsoft.com/en-us/library/cc980922.aspx

物价感观 2024-07-11 16:15:26

您可以使用 Microsoft 的 MapPoint Web 服务。

我创建了一个关于如何将地址转换为地理编码(纬度/经度)。

You can use Microsoft's MapPoint Web Services.

I created a blog entry on how to convert an address to a GeoCode (lat/long).

岁月无声 2024-07-11 16:15:26

我想我应该在列表中再添加一个。 德克萨斯 A&M 在这里提供价格相当合理的服务:http://geoservices.tamu.edu/Services/ 地理编码

如果您有大量地址需要进行地理编码并且不想向 Google 或 Microsoft 支付 10k,那么 是一个不错的选择。 我们最终仍然在谷歌地图中使用返回的数据。

Thought I would add one more to the list. Texas A&M has a pretty decently priced service here: http://geoservices.tamu.edu/Services/Geocode/

A good option if you have a pretty large set of addresses to geocode and don't want to pat 10k to Google or Microsoft. We still ended up using the returned data in a Google Map.

绿光 2024-07-11 16:15:26

您问的是地理编码器。
Google 为此提供了一个 API。
另一个提供商也是如此。

您可以在 我当前位置 .net 中查看实现演示

you are asking about Geocoder.
Google provide an API for this.
so does another provider for this.

you can see the demo of implementation in My Current Location .net

饮湿 2024-07-11 16:15:26

USC WebGIS Geocoder 是免费的,并提供多个 API,或者您也可以上传数据库以进行在线批处理。

The USC WebGIS Geocoder is free and offers several API's, or you can upload a database for online batch processing.

太阳哥哥 2024-07-11 16:15:26

如果您需要一次性解决方案,您可以尝试:https://addresstolatlong.com/

我已经使用过它很长一段时间以来,它对我来说效果很好。

If you need a one off solution, you can try: https://addresstolatlong.com/

I've used it for a long time and it has worked pretty well for me.

微凉徒眸意 2024-07-11 16:15:26

雅虎! 与 Google 的 API 不同,地图网络服务 - 地理编码 API 可准确地对英国邮政编码进行地理编码。

不幸的是,雅虎已弃用此服务,您可以访问 http://developer.yahoo.com/geo/placefinder / 用于雅虎服务

Yahoo! Maps Web Services - Geocoding API accurately geocodes UK postcodes, unlike Google's API.

Unfortunately yahoo has deprecated this service, you could visit http://developer.yahoo.com/geo/placefinder/ for yahoo's service

牛↙奶布丁 2024-07-11 16:15:25

没什么可补充的,但我在之前的工作中获得了很多 GIS 和地理编码方面的实际经验。 我记得是这样的:

如果您的应用程序“偶尔”需要,我肯定会推荐 Google 或 Yahoo Geocoding API,但请仔细阅读他们的许可条款。

我知道 Google 地图 API 一般而言即使是商业网页也很容易获得许可,但不能在付费访问情况下使用。 换句话说,您可以使用它来做广告或提供可增加广告收入的服务,但您不能向访问您网站的人收费,甚至不能将其置于密码系统后面。

尽管有这些限制,它们都是很好的选择,因为它们经常更新街道数据库。 大多数免费后端工具和库都使用不经常更新的人口普查和 TIGER 道路数据,因此您不太可能在快速增长的区域或新分区中成功对地址进行地理编码。

大多数服务还限制您每天可以进行的地理编码查询的数量,因此可以查找添加到数据库中的新客户的地址,但是如果您运行一个批处理作业来提供数千个地址如果您将数据库导入地理编码器,您就会被关闭。

我认为尚未提及这一点,但 ESRI 有 ArcWeb Web 服务包括地理编码,尽管它们不是很便宜。 上次我使用它们时,每次查找的费用约为 1.5 美分,但您必须预付一定金额才能开始。 同样,主要优点是他们使用的道路数据会及时更新,并且您可以在 Google 不允许的商业情况下使用这些数据。 ArcWeb 服务还将提供高分辨率卫星和航空照片aGoogle 地图,同样按请求定价。

如果您想推出自己的数据或访问更准确的数据,您可以从 TeleAtlas,但这并不便宜。 如果您的需求非常本地化,您只能购买州或县的数据。 有多个数据层 - 仅 GIS 功能,GIS 加上详细的街道,所有这些加上地理编码数据,所有这些加上路线的交通流/方向/速度限制。 当然,随着等级的提升,价格也会上涨。

最后,关于地理编码的维基百科文章提供了一些有关算法和技术的有用信息。 即使您不是在自己的代码中执行此操作,了解各种数据源可能出现的错误类型和准确性也很有用。

Nothing much new to add, but I have had a lot of real-world experience in GIS and geocoding from a previous job. Here is what I remember:

If it is a "every once in a while" need in your application, I would definitely recommend the Google or Yahoo Geocoding APIs, but be careful to read their licensing terms.

I know that the Google Maps API in general is easy to license for even commercial web pages, but can't be used in a pay-to-access situation. In other words you can use it to advertise or provide a service that drives ad revenue, but you can't charge people to acess your site or even put it behind a password system.

Despite these restrictions, they are both excellent choices because they frequently update their street databases. Most of the free backend tools and libraries use Census and TIGER road data that is updated infrequently, so you are less likely to successfully geocode addresses in rapidly growing areas or new subdivisions.

Most of the services also restrict the number of geocoding queries you can make per day, so it's OK to look up addresses of, say, new customers who get added to your database, but if you run a batch job that feeds thousands of addresses from your database into the geocoder, you're going to get shutoff.

I don't think this one has been mentioned yet, but ESRI has ArcWeb web services that include geocoding, although they aren't very cheap. Last time I used them it cost around 1.5cents per lookup, but you had to prepay a certain amount to get started. Again the major advantage is that the road data they use is kept up to date in a timely manner and you can use the data in commercial situations that Google doesn't allow. The ArcWeb service will also serve up high-resolution satellite and aerial photos a la Google Maps, again priced per request.

If you want to roll your own or have access to much more accurate data, you can purchase subscriptions to GIS data from companies like TeleAtlas, but that ain't cheap. You can buy only a state or county worth of data if your needs are extremely local. There are several tiers of data - GIS features only, GIS plus detailed streets, all that plus geocode data, all of that plus traffic flow/direction/speed limits for routing. Of course, the price goes up as you go up the tiers.

Finally, the Wikipedia article on Geocoding has some good information on the algorithms and techniques. Even if you aren't doing it in your own code, it's useful to know what kind of errors and accuracy you can expect from various kinds of data sources.

云朵有点甜 2024-07-11 16:15:25

谷歌有一个地理编码 API,似乎对于他们拥有谷歌地图数据的大多数位置都运行良好。

http://googlemapsapi.blogspot.com/2006/06/geocoding-at -last.html

他们提供在线地理编码(通过 JavaScript):

http://code.google.com/apis/maps/documentation/services.html#Geocoding

或后端地理编码(通过 HTTP 请求):

http://code.google.com/apis/maps/documentation/services.html#Geocoding_Direct

数据通常与使用的数据相同由谷歌地图本身。 (请注意,也有一些例外,例如英国或以色列,其数据来自不同的来源且质量略有下降)

Google has a geocoding API which seems to work pretty well for most of the locations that they have Google Maps data for.

http://googlemapsapi.blogspot.com/2006/06/geocoding-at-last.html

They provide online geocoding (via JavaScript):

http://code.google.com/apis/maps/documentation/services.html#Geocoding

Or backend geocoding (via an HTTP request):

http://code.google.com/apis/maps/documentation/services.html#Geocoding_Direct

The data is usually the same used by Google Maps itself. (note that there are some exceptions to this, such as the UK or Israel, where the data is from a different source and of slightly reduced quality)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文