使用D3更改形状文件投影以进行可视化

时间:2023-02-03 20:57:47

I am trying to produce a visualisation involving a map of the UK and all of it's ~650 electoral constituencies. I have drawn the map by following this excellent tutorial http://bost.ocks.org/mike/map/ and it works great. However the only source I can find for the constituencies is Ordnance Survey (Natural Earth has counties but not constituencies). The problem is the OS constituency files do not contain they same type of coordinates (as you may be able to tell, i'm not a GIS expert), they use the transverse Mercator projection. Here are the properties of the .prj file of the data I am trying to convert from:

我正在尝试制作一个涉及英国地图和所有约650个选区的可视化图像。我按照这个优秀的教程http://bost.ocks.org/mike/map/绘制了地图,效果很好。然而,我能为选区找到的唯一来源是军械测量(自然地球有县但没有选区)。问题是操作系统选区文件不包含相同类型的坐标(您可以告诉我,我不是GIS专家),他们使用横向墨卡托投影。以下是我要转换的数据的.prj文件的属性:

PROJCS["British_National_Grid",GEOGCS["GCS_OSGB_1936",DATUM["D_OSGB_1936",SPHEROID["Airy_1830",6377563.396,299.3249646]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",400000],PARAMETER["False_Northing",-100000],PARAMETER["Central_Meridian",-2],PARAMETER["Scale_Factor",0.999601272],PARAMETER["Latitude_Of_Origin",49],UNIT["Meter",1]]

My question is: How can I convert this for projection in D3? I have ogr2ogr and TopJson installed but not sure if these can do it and I can't find information anywhere as I don't have enough foundation knowledge.

我的问题是:如何在D3中将其转换为投影?我安装了ogr2ogr和TopJson但不确定这些是否可以做到这一点我无法在任何地方找到信息,因为我没有足够的基础知识。

TIA

1 个解决方案

#1


8  

Spatial data is specified in a given coordinate system. This coordinate system is used to project coordinates to a particular point in space, such as a map canvas. There are literally hundreds of different coordinate systems for geographical data. One of the reasons for this is that the earth is not well-behaved with respect to projections -- it's not a perfect sphere and different coordinate systems tend to work best in different places ("work best" refers to how accurate they are once you project a point onto the earth's surface). You can find more information on wikipedia.

空间数据在给定的坐标系中指定。此坐标系用于将坐标投影到空间中的特定点,例如地图画布。实际上有数百种不同的地理数据坐标系。造成这种情况的原因之一是地球在投影方面表现不佳 - 它不是一个完美的球体,不同的坐标系统往往在不同的地方效果最好(“最好的工作”指的是一旦你有多准确它们在地球表面投射一个点)。您可以在*上找到更多信息。

Defining a coordinate system and projection is not necessarily difficult or much work, but it needs to be done before it can be used. This is the reason you weren't able to use your data out of the box -- it uses a coordinate system that D3 doesn't know about (British National Grid). So your options are to convert it into one that D3 does know about, or implement your coordinate system in D3. The former is almost always the easier way to go.

定义坐标系和投影不一定困难或工作量很大,但需要在使用之前完成。这就是您无法使用开箱即用数据的原因 - 它使用D3不了解的坐标系(英国国家电网)。因此,您可以选择将其转换为D3知道的,或者在D3中实现您的坐标系。前者几乎总是更容易的方式。

The command ogr2ogr output.shp input.shp -t_srs "+proj=longlat +ellps=WGS84 +no_defs +towgs84=0,0,0" converts your input shapefile (a file format for geographical data) input.shp into Universal Transverse Mercator (UTM) WGS84 format (this is what the t_srs string means, more on wikipedia) in output.shp, regardless of the coordinate system used in the input.

命令ogr2ogr output.shp input.shp -t_srs“+ proj = longlat + ellps = WGS84 + no_defs + towgs84 = 0,0,0”将输入的shapefile(地理数据的文件格式)input.shp转换为Universal Transverse Mercator (UTM)WGS84格式(这是t_srs字符串的含义,在*上更多),无论输入中使用的坐标系如何,都在output.shp中。

The target coordinate system argument given to t_srs can be an explicit definition (like in the example above), a reference to a well-known coordinate system or a file that contains the definition. A list of well-known coordinate systems can be found here for example.

给予t_srs的目标坐标系参数可以是显式定义(如上例中所示),对已知坐标系的引用或包含该定义的文件。例如,可以在此处找到众所周知的坐标系列表。

#1


8  

Spatial data is specified in a given coordinate system. This coordinate system is used to project coordinates to a particular point in space, such as a map canvas. There are literally hundreds of different coordinate systems for geographical data. One of the reasons for this is that the earth is not well-behaved with respect to projections -- it's not a perfect sphere and different coordinate systems tend to work best in different places ("work best" refers to how accurate they are once you project a point onto the earth's surface). You can find more information on wikipedia.

空间数据在给定的坐标系中指定。此坐标系用于将坐标投影到空间中的特定点,例如地图画布。实际上有数百种不同的地理数据坐标系。造成这种情况的原因之一是地球在投影方面表现不佳 - 它不是一个完美的球体,不同的坐标系统往往在不同的地方效果最好(“最好的工作”指的是一旦你有多准确它们在地球表面投射一个点)。您可以在*上找到更多信息。

Defining a coordinate system and projection is not necessarily difficult or much work, but it needs to be done before it can be used. This is the reason you weren't able to use your data out of the box -- it uses a coordinate system that D3 doesn't know about (British National Grid). So your options are to convert it into one that D3 does know about, or implement your coordinate system in D3. The former is almost always the easier way to go.

定义坐标系和投影不一定困难或工作量很大,但需要在使用之前完成。这就是您无法使用开箱即用数据的原因 - 它使用D3不了解的坐标系(英国国家电网)。因此,您可以选择将其转换为D3知道的,或者在D3中实现您的坐标系。前者几乎总是更容易的方式。

The command ogr2ogr output.shp input.shp -t_srs "+proj=longlat +ellps=WGS84 +no_defs +towgs84=0,0,0" converts your input shapefile (a file format for geographical data) input.shp into Universal Transverse Mercator (UTM) WGS84 format (this is what the t_srs string means, more on wikipedia) in output.shp, regardless of the coordinate system used in the input.

命令ogr2ogr output.shp input.shp -t_srs“+ proj = longlat + ellps = WGS84 + no_defs + towgs84 = 0,0,0”将输入的shapefile(地理数据的文件格式)input.shp转换为Universal Transverse Mercator (UTM)WGS84格式(这是t_srs字符串的含义,在*上更多),无论输入中使用的坐标系如何,都在output.shp中。

The target coordinate system argument given to t_srs can be an explicit definition (like in the example above), a reference to a well-known coordinate system or a file that contains the definition. A list of well-known coordinate systems can be found here for example.

给予t_srs的目标坐标系参数可以是显式定义(如上例中所示),对已知坐标系的引用或包含该定义的文件。例如,可以在此处找到众所周知的坐标系列表。