在哪里可以找到在墨卡托投影中绘制美国所需的坐标?

发布于 2024-08-22 09:22:47 字数 525 浏览 16 评论 0原文

所以我正在编写一个 Javascript 库,它采用 x,y 坐标并使用它们来绘制美国地图。为此,我需要找到绘制每个状态所需的坐标数据。维基百科上的这张地图是我所需要的一个很好的例子,因为 SVG 文件包含构成每个州的形状,并且很好地标记了: http://upload.wikimedia.org/wikipedia/commons/3/32/Blank_US_Map.svg

我还有一组网站需要放置在此地图。由于我知道每个站点的纬度和经度,因此我可以使用它在地图上的适当位置绘制每个站点。不幸的是,为此,我的地图需要使用墨卡托投影,以便可以轻松地将纬度、经度映射到 x、y 像素坐标。

我上面提到的维基百科地图使用了一些其他投影,所以我不能将它用于此目的。有谁知道在哪里可以找到墨卡托投影中的此类地图数据?任何数据格式都可以,只要我可以以编程方式获取用于绘制每个状态的坐标并识别哪些形状构成每个状态。

So I'm writing a Javascript library that takes x,y coordinates and uses them to draw a map of the US. To do this, I need to find the coordinate data necessary to draw each state. This map on Wikipedia is a great example of what I need, because the SVG file contains the shapes that make up each state nicely labeled: http://upload.wikimedia.org/wikipedia/commons/3/32/Blank_US_Map.svg

I also have a set of sites which I need to place on this map. Since I know the latitude and longitude of each site, I can use that to draw each site in its appropriate place on the map. Unfortunately, for this to work my map needs to use the Mercator projection, so that there can be an easy mapping of lat,long to x,y pixel coordinates.

The Wikipedia map I mentioned above uses some other projection, so I can't use it for this purpose. Does anyone know where I can find this type of map data in the Mercator projection? Any data format is fine, so long as I can programmatically get at the coordinates which are used to draw each state and identify which shapes comprise each state.

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

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

发布评论

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

评论(9

眼泪都笑了 2024-08-29 09:22:47

Kevin McCurley 创建了一些美国地图,包括所有 50 个国家的地图状态,在墨卡托投影中。如果您查看最终链接的源代码,它由表示各州轮廓的(纬度、经度)对组成,然后将其转换为(x,y)对以以 svg 格式显示。他允许的用法是

请随意在您的
自己的乐趣,但我会很感激
因创造而获得荣誉
他们。享受...

我不知道这对你来说是否足够好。

Kevin McCurley has created some maps of the United States, including a map of all 50 states, in the Mercator projection. If you look at the source of that final link, it consists of (latitude, longitude) pairs for the outlines of the states, which are then transformed into (x, y) pairs for display in the svg format. His allowed usage is

Feel free to use these files in your
own fun, but I would appreciate
receiving credit for having created
them. Enjoy...

I don't know if that's good enough for you.

玩心态 2024-08-29 09:22:47

这是一个 GIS 问题,除非使用正确的工具,否则很难解决。

  • 使用QGIS打开美国 Shapefile 数据

    编辑 如果我链接到的 shapefile 不完全是您要查找的形状文件,则 Google 搜索“US shapefiles”。 Shapefile 实际上是一组地理空间文件(而不仅仅是一个文件)。

  • 将图层重新投影到指定的投影

    编辑这可能会很麻烦,但以防万一,它不会 ogr (见下文)可以重新投影。 EPSG 是从空间参考

  • 使用ogr2ogr (cheatsheet) 或将数据转换为的转换器插件KML。这将以 Google 地图/地球/人类可读格式输出您的数据,其中包含坐标

编辑 2
您用什么来显示在线地图?您是否考虑过 openlayersGoogle 地图 API地图服务器

编辑 3
我在我拥有的一些数据上测试了我的方法并且它有效,这是使用“状态和等效(当前)”层的一个多边形的示例输出:

<Placemark>
      <name>American Samoa</name>
      <styleUrl>#PolyStyle00</styleUrl>
      <Snippet></Snippet>
      <MultiGeometry>
        <Polygon>
          <tessellate>1</tessellate>
          <extrude>0</extrude>
          <altitudeMode>clampToGround</altitudeMode>
          <outerBoundaryIs><LinearRing><coordinates> -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000100,0.000000 -0.001536,-0.000100,0.000000 -0.001536,-0.000100,0.000000 -0.001536,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000</coordinates>
            </LinearRing>
          </outerBoundaryIs>
        </Polygon>

This is a GIS question and would not be solved easily unless you're using the proper tools.

  • Use QGIS to open the US Shapefile data

    EDIT In the case the shapefiles I linked to are not exactly the ones you were looking for then Google for "US shapefiles". Shapefiles are actually a group of geospatial (and not just one file).

  • Reproject your layer to the specified projection

    EDIT this can be a hassle, but just in case, it doesn't ogr (see below) can reproject. EPSG are obtained from spatial reference

  • Use ogr2ogr (cheatsheet) or the converter plugin to convert your data to KML. This will output your data in a Google maps/earth/human readable format that will have the coordinates in them

EDIT 2
What are you using to display the online maps? have you considered openlayers or Google maps API or mapserver

EDIT 3
I tested my method on some data I have and it works, here's a sample output for one polygon using "State and Equivalent (Current)" layer:

<Placemark>
      <name>American Samoa</name>
      <styleUrl>#PolyStyle00</styleUrl>
      <Snippet></Snippet>
      <MultiGeometry>
        <Polygon>
          <tessellate>1</tessellate>
          <extrude>0</extrude>
          <altitudeMode>clampToGround</altitudeMode>
          <outerBoundaryIs><LinearRing><coordinates> -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000100,0.000000 -0.001536,-0.000100,0.000000 -0.001536,-0.000100,0.000000 -0.001536,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000100,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001537,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000 -0.001536,-0.000099,0.000000</coordinates>
            </LinearRing>
          </outerBoundaryIs>
        </Polygon>
短叹 2024-08-29 09:22:47

从头开始

制作新地图可以轻松地从免费的shapefile 由 USGS 以相当高的分辨率提供。实际上,有人已经创建了 shapefile->svg 翻译脚本 这就是为你做的,但请注意该项目已移至 GitHub

不幸的是,shapefile位于NAD83投影中,因此需要在您之前将其重新投影到墨卡托运行脚本。同样,这是一个已经解决的问题,也是 GIS 中非常常见的事情,并且只需要要做一次。为此,我建议使用 MapWindow 因为这样做很简单。

要将 shapefile 重新投影到墨卡托,您需要下载并安装 MapWindow。当您运行该程序时,您可以在主窗口中看到一个插件菜单,并且您需要启用GIS工具插件。然后单击绿色的“加号”符号将 shapefile 添加到 MapWindow 中,它应该在屏幕上呈现美国。

当您将 shapefile 导入到 MapWindow 中后,您将重新投影它。为此,请单击GIS 工具 -> 向量 -> 重新投影形状文件,它应该打开一个对话框。

您看到的第一个对话框询问您想要什么投影:

  • 类别:投影坐标系
  • 组:世界
  • 名称:墨卡托(世界)

第二个可能不显示,但如果显示,则会询问当前投影:

  • 类别:地理坐标系
  • 组:北美
  • 名称:北美基准面 1983

此过程应创建一个名为 statesp020_reprojected 或类似名称的新形状文件。

您现在需要使用将 shpaefile 转换为 SVG上面的脚本。我不会费心写这方面的说明,因为我以前没有尝试过,但我相信你能弄清楚!

A new map from scratch

It's easy to create a map from the free shapefile which is provided in pretty high resolution by the USGS. Actually, some guy has already created a shapefile->svg translation script that does just that for you but note that the project has been moved to GitHub.

Unfortunately the shapefile is in the NAD83 projection so it needs to be reprojected to Mercator before you run the script. Again, this is an already solved problem and a very common thing to do in GIS's and only needs to be done once. For this I'm going to suggest MapWindow because it's trivial to do in that.

To reproject the shapefiles to Mercator you need to download and install MapWindow. When you run the program you can see a Plug-ins menu in the main window and you're going to need to enable the GIS Tools plugin. Then you click the green "plus" symbol to add the shapefile into MapWindow and it should render the USA on the screen.

When you've imported the shapefile into MapWindow you're going to reproject it. To do that you click on the GIS Tools -> Vector -> Reproject a Shapefile and it should open up a dialog box.

The first dialog you see asks about what projection you want:

  • Category: Projected Coordinate Systems
  • Group: World
  • Name: Mercator (world)

The second might not show up but if it does it's asking about the current projection:

  • Category: Geographic Coordinate Systems
  • Group: North America
  • Name: North American Datum 1983

This process should create a new shapefile called statesp020_reprojected or something like that.

You now need to translate the shpaefile to SVG using the script above. I'm not going to bother with writing instructions on that because I haven't tried it before, but I'm sure you can figure it out!

机场等船 2024-08-29 09:22:47

这里:http://www.nws.noaa.gov/ geodata/catalog/national/html/us_state.htm
您可以下载包含数据的 shp 文件。 shape 格式包含一个带有一些属性的 dbf,其中包括每个状态的坐标。

另外,您可以使用 shp2text 提取所有信息。

编辑:
地图中的数据采用 1983 年北美基准面,但您可以使用 此处的电子表格和公式可转换为墨卡托 (UTM)。

Here: http://www.nws.noaa.gov/geodata/catalog/national/html/us_state.htm
you can download a shp file with the data. The shape format includes a dbf with some attributes, including coordinates for each state.

Also, you can use shp2text to extract all the information.

Edit:
Data in the map is in North American Datum of 1983, but you can use the Spreadsheet and formulas here to convert to Mercator (UTM).

那小子欠揍 2024-08-29 09:22:47

你看过NIMA的产品吗? http://egsc.usgs.gov/nimamaps/https://www1.nga.mil/ProductsServices/Pages/default.aspx 他们有各种各样的地图,格式等,并且全部由我们纳税人支付,因此公众可以使用很多内容。地图的好第一站。

Have you looked at NIMA products? http://egsc.usgs.gov/nimamaps/ and https://www1.nga.mil/ProductsServices/Pages/default.aspx They have a variety of maps, formats, etc. and all paid for by us taxpayers, so much is available to the public. Good first stop for maps.

╰沐子 2024-08-29 09:22:47

我从未做过您所询问的那种工作,但在我看来,来自美国陆军工程兵团的这些数据将对您有用:

http://crunch.tec.army.mil/software/corpscon/corpscon.html

I've never done the sort of work you're asking about, but it looks to me like these data from the US Army Corps of Engineers will be useful for you:

http://crunch.tec.army.mil/software/corpscon/corpscon.html

囍笑 2024-08-29 09:22:47

visokio.com 在此提供可下载的矢量地图集:http://www.visokio.com/maps
其中大多数支持十进制纬度/经度坐标。

然而,似乎所有内容都采用专有格式,只能使用自己的软件查看。不过,有试用版软件可用。

嗯。

编辑:浏览维基百科时遇到这些:

visokio.com has downloadable collections of vector maps here: http://www.visokio.com/maps
most of them support decimal latitude/longitude coordinates.

however it looks like all are in a propetiary format viewable only with their own software. a trial software is available, tho.

hth.

edit: come across these when browsing around wikipedia:

饮湿 2024-08-29 09:22:47

Indieprojector 应该能够生成您需要的文件。它是一个免费的在线工具,可以重新投影任何 shapefile 并将其再次导出为 .svg。他们甚至在线包含美国各州,因此您无需弄乱 Shapefile。

Indieprojector should be able to generate the files you need. It's a free online tool that reprojects any shapefile and exports it again to .svg. They even have US States included online so you won't need to mess with the Shapefile.

挽容 2024-08-29 09:22:47

这是一个 stackoverflow 响应,其中包含从 lat long 到 Mercator 的 JS 数学

将纬度/经度转换为 X/Y 坐标

下载上面列出的形状文件之一,然后使用 OGR 执行 ogr2ogr 转换为 CSV

在此处获取 OGR

链接

这是 OGR 的文档

链接

这是输出格式的名称

链接

考虑到您的声誉我知道一旦您将其转换为 CSV,您就可以处理它

Here is a stackoverflow response with the JS math from lat long to mercator

Convert Lat/Longs to X/Y Co-ordinates

download one of those shapefiles listed above and then use OGR to do ogr2ogr for converting to CSV

get OGR here

Link

Here is the doc for OGR

Link

Here is the name of the output formats

Link

Given your reputation I know you can handle it once you get it to CSV

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