Pregunta

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:

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.

TIA

¿Fue útil?

Solución

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.

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.

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top