找到一个城市的中心点 [英] Finding the center point of a city
问题描述
<有没有更准确的方法?我想避免购买另一个数据库。我们还没有购买完整的数据库,因此我不能只尝试它并将结果与Google Maps进行比较。实际上,邮政编码并不总是包含城市。邮编是用于定义邮政地址的任意区域。
编辑:并非总是假设所有邮政编码的总和将与城市边界或将检索您正确的质心。
您最好的办法是获得一个含有空间数据的countys表。
在PostGIS中,一个简单的ST_Centroid(GeometryField)就足以让你获得多边形的质心。这适用于任何类型的多边形。
如果您在美国,可能存在可在互联网上获得的公共县/城市/州数据集。考虑使用GIS工具来完成这项工作。
We are purchasing a database of zip codes and their corresponding Lat/Long. I want to store cities in a separate table with a lat/long point representing the center of the city. Can I calculate that based on taking all of the zips that belong to that city, getting the min/max points for each direction, and taking the center point of the resulting rectangle?
Is there a more accurate method? I want to avoid purchasing another DB. We haven't purchased the full DB yet so I can't just try it and compare the results to Google Maps.
Well actually ZIP codes do not always encompass cities. Zip codes are arbitrary regions used to defined postal addresses.
Edit: Not always your assumption that the sum of all ZIP Codes will correspond to the city boundary or will retrieve you the correct centroid.
Your best bet is to get a countys table with spatial data in it.
In PostGIS a simple ST_Centroid(GeometryField) would suffice to get you the centroid of a polygon. That works out for any type of polygons.
If you are in the US, probably exists a public county/cities/states dataset availuable on the internet. Consider GIS tools for doing this work.
这篇关于找到一个城市的中心点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!