在谷歌地图上覆盖 ESRI shapefile 的最佳方法?

发布于 2024-10-24 05:15:40 字数 204 浏览 7 评论 0 原文

在 Google 地图中叠加 shapefile 的最佳方法是什么?

经过一番阅读后发现,将 shapefile 转换为 KML 并在 Google 地图中覆盖 KML 是一种选择。如果是这种情况,如何将 shapefile 转换为 KML?

我相信会有一些开源工具可用于这种转换。谁能指出一个工具可以将 shapefile 转换为 KML 而不会丢失任何数据?

What is the best way to overlay a shapefile in Google Maps?

After some reading suggests that, converting shapefile into KML and overlaying KML in Google map is an option. If that is the case, how do I convert a shapefile into KMLs?

I believe there would be a few open source tools available for this conversion. Can anyone point to a tool to covert a shapefile to KML without any loss of data?

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

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

发布评论

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

评论(7

烟花肆意 2024-10-31 05:15:40

我喜欢使用(开源且 GUI 友好)Quantum GIS 将 shapefile 转换为 kml。

Google Maps API 仅支持KML 标准的子集。限制之一是文件大小。

要减小文件大小,您可以使用Quantum GIS 的“简化几何图形”功能。这会“平滑”多边形。

然后你可以选择你的图层并对其进行“另存为kml”。

如果您需要处理一堆文件,可以使用 osgeo4w shell 中的 Quantum GIS 的 ogr2ogr 命令对过程进行批处理。

最后,我建议压缩您的 kml(使用您最喜欢的压缩程序)以减小文件大小并将其另存为 kmz。

I like using (open source and gui friendly) Quantum GIS to convert the shapefile to kml.

Google Maps API supports only a subset of the KML standard. One limitation is file size.

To reduce your file size, you can Quantum GIS's "simplify geometries" function. This "smooths" polygons.

Then you can select your layer and do a "save as kml" on it.

If you need to process a bunch of files, the process can be batched with Quantum GIS's ogr2ogr command from osgeo4w shell.

Finally, I recommend zipping your kml (with your favorite compression program) for reduced file size and saving it as kmz.

混浊又暗下来 2024-10-31 05:15:40

自 2019 年 3 月 12 日起,FusionTables 已不再存在...

将 Shapefile 导入 Google FusionTables ( http://www.google.com/fusiontables )使用 http://www.shpescape.com/ 从那里您可以通过多种方式使用数据,例如。使用 GoogleMaps 显示它。

as of 12.03.2019 FusionTables is no more...

Import the Shapefile into Google FusionTables ( http://www.google.com/fusiontables ) using http://www.shpescape.com/ and from there you can use the data in a number of ways, eg. display it using GoogleMaps.

山色无中 2024-10-31 05:15:40

我不会使用 KML。相反,请使用 GeoJSON,您现在可以在 Google Maps API 中原生使用它。这是一个较新的功能,原始响应中不存在。

无论如何,只需打开 Quantum GIS 中的 SHP 文件,然后您就可以以任何您喜欢的格式输出它(KML、GeoJSON)。

如果您使用 Google Maps for Work,我发现了一个高级扩展,可以直接处理加载 shapefile,您可以直接连接到从 ESRI 生成的 shapefile。我在 CMaps 网站上进行了搜索,发现这个片段按州形状文件加载了美国: https: //gmapsplugin.net/cmapsanalytics/assets/shapes/usstates.shp

var cMap = new centigon.locationIntelligence.MapView();
    cMap.key([your_api_key]);


    cMap.layerNames(["Basic Shapes"]);
    cMap.dbfKeys([['Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','District of Columbia','Florida','Georgia','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina','North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont','Virginia','Washington','West Virginia','Wisconsin','Wyoming']]);
    cMap.userShapeKeys([['Massachusetts','Minnesota','Montana','North Dakota','Hawaii','Idaho','Washington','Arizona','California','Colorado','Nevada','New Mexico','Oregon','Utah','Wyoming','Arkansas','Iowa','Kansas','Missouri','Nebraska','Oklahoma','South Dakota','Louisiana','Texas','Connecticut','New Hampshire','Rhode Island','Vermont','Alabama','Florida','Georgia','Mississippi','South Carolina','Illinois','Indiana','Kentucky','North Carolina','Ohio','Tennessee','Virginia','Wisconsin','West Virginia','Delaware','District of Columbia','Maryland','New Jersey','New York','Pennsylvania','Maine','Michigan','Alaska']]); 
    cMap.labels([['Massachusetts','Minnesota','Montana','North Dakota','Hawaii','Idaho','Washington','Arizona','California','Colorado','Nevada','New Mexico','Oregon','Utah','Wyoming','Arkansas','Iowa','Kansas','Missouri','Nebraska','Oklahoma','South Dakota','Louisiana','Texas','Connecticut','New Hampshire','Rhode Island','Vermont','Alabama','Florida','Georgia','Mississippi','South Carolina','Illinois','Indiana','Kentucky','North Carolina','Ohio','Tennessee','Virginia','Wisconsin','West Virginia','Delaware','District of Columbia','Maryland','New Jersey','New York','Pennsylvania','Maine','Michigan','Alaska']]); 

    cMap.polyDataSources([centigon.locationIntelligence.CMapAnalytics.DATA_PROVIDERS.SHAPE_DATAPROVIDER]);
    cMap.layerTypes([centigon.mapping.Layer.TYPE.POLY]);
    cMap.locations([["https://gmapsplugin.net/cmapsanalytics/assets/shapes/usstates.shp"]]);

    cMap.panTo("USA");
    cMap.zoomLevel(3);

I would not use KML. Instead, use GeoJSON which you can natively consume in Google Maps API now. It is a newer feature that didn't exist from the original responses.

In any case, simply open the SHP file in Quantum GIS, and then you can output it in any format you like (KML, GeoJSON).

If you are using Google Maps for Work, I found a premium extension that handles loading shapefiles directly where you can just connect direct to the shapefile that you generate from ESRI. I did a search on the CMaps site and found this snippet which loaded US by state shapefile: https://gmapsplugin.net/cmapsanalytics/assets/shapes/usstates.shp

var cMap = new centigon.locationIntelligence.MapView();
    cMap.key([your_api_key]);


    cMap.layerNames(["Basic Shapes"]);
    cMap.dbfKeys([['Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','District of Columbia','Florida','Georgia','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina','North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont','Virginia','Washington','West Virginia','Wisconsin','Wyoming']]);
    cMap.userShapeKeys([['Massachusetts','Minnesota','Montana','North Dakota','Hawaii','Idaho','Washington','Arizona','California','Colorado','Nevada','New Mexico','Oregon','Utah','Wyoming','Arkansas','Iowa','Kansas','Missouri','Nebraska','Oklahoma','South Dakota','Louisiana','Texas','Connecticut','New Hampshire','Rhode Island','Vermont','Alabama','Florida','Georgia','Mississippi','South Carolina','Illinois','Indiana','Kentucky','North Carolina','Ohio','Tennessee','Virginia','Wisconsin','West Virginia','Delaware','District of Columbia','Maryland','New Jersey','New York','Pennsylvania','Maine','Michigan','Alaska']]); 
    cMap.labels([['Massachusetts','Minnesota','Montana','North Dakota','Hawaii','Idaho','Washington','Arizona','California','Colorado','Nevada','New Mexico','Oregon','Utah','Wyoming','Arkansas','Iowa','Kansas','Missouri','Nebraska','Oklahoma','South Dakota','Louisiana','Texas','Connecticut','New Hampshire','Rhode Island','Vermont','Alabama','Florida','Georgia','Mississippi','South Carolina','Illinois','Indiana','Kentucky','North Carolina','Ohio','Tennessee','Virginia','Wisconsin','West Virginia','Delaware','District of Columbia','Maryland','New Jersey','New York','Pennsylvania','Maine','Michigan','Alaska']]); 

    cMap.polyDataSources([centigon.locationIntelligence.CMapAnalytics.DATA_PROVIDERS.SHAPE_DATAPROVIDER]);
    cMap.layerTypes([centigon.mapping.Layer.TYPE.POLY]);
    cMap.locations([["https://gmapsplugin.net/cmapsanalytics/assets/shapes/usstates.shp"]]);

    cMap.panTo("USA");
    cMap.zoomLevel(3);
天邊彩虹 2024-10-31 05:15:40

您的意思是 Esri shapefile 中的 shapefile 吗?无论哪种方式,您都应该能够使用 ogr2ogr 执行转换,该转换可在 GDAL 包。您需要 .shp 文件,最好还需要相应的 .dbf 文件(它将提供上下文信息)。

另外,在将 shapefile 转换为 KML 之前,请考虑使用 MapShaper 等工具来降低其复杂性;您将根据需要的详细信息数量大幅减少文件大小。

Do you mean shapefile as in an Esri shapefile? Either way, you should be able to perform the conversion using ogr2ogr, which is available in the GDAL packages. You need the .shp file and ideally the corresponding .dbf file (which will provide contextual information).

Also, consider using a tool like MapShaper to reduce the complexity of your shapefiles before transforming them into KML; you'll reduce filesize substantially depending on how much detail you need.

云仙小弟 2024-10-31 05:15:40

适用于 ArcGIS 9 的免费“导出到 KML”脚本

这是某人找到的可用方法的列表

另外,在我看来,多边形图层最有效的表示是使用 Google Maps API 的折线编码,它可以显着压缩经纬度数据。但进入该格式需要一些工作:使用 ArcMap 将 Shape 导出为纬度/经度坐标,然后使用 Google Maps API 转换为折线。

Free "Export to KML" script for ArcGIS 9

Here is a list of available methods that someone found.

Also, it seems to me that the most efficient representation of a polygon layer is by using Google Maps API's polyline encoding, which significantly compresses lat-lng data. But getting into that format takes work: use ArcMap to export Shape as lat/lng coordinates, then convert into polylines using Google Maps API.

念﹏祤嫣 2024-10-31 05:15:40

只是为了更新这些答案,ESRI 包含了这个工具,称为 映射到 KML 工具。

只需导入所需的图层(矢量或栅格)并选择输出位置、分辨率等。非常简单的工具。

Just to update these answers, ESRI has included this tool, known as Layer to KML in ArcMap 10.X. Also, a Map to KML tool exists.

Simply import the desired layer (vector or raster) and choose the output location, resolution, etc. Very simple tool.

没︽人懂的悲伤 2024-10-31 05:15:40

2018 年了...我发现了这个很棒的在线工具 http://mapshaper.org/ 可以从 ESRI 进行转换shapefile 到 SVG、TopoJSON、GeoJSON。

以下是如何使用它的说明 https://www .statsilk.com/maps/convert-esri-shapefile-map-geojson-format

快速而简单! :)

2018 already... I've found this fantastic online tool http://mapshaper.org/ to convert from ESRI shapefiles to SVG, TopoJSON, GeoJSON.

Here is the explanation of how to use it https://www.statsilk.com/maps/convert-esri-shapefile-map-geojson-format

Fast and straightforward! :)

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