1

I'm trying to get data for map of Poland. I found WFS service that provides GML files. It is located under:

http://sdi.geoportal.gov.pl/wfs_prg/wfservice.aspx?request=GetCapabilities&service=WFS

I'm able to all provinces of Poland using this request:

http://sdi.geoportal.gov.pl/wfs_prg/wfservice.aspx?request=GetFeature&version=1.1.0&service=WFS&typename=gmgml:WOJEWODZTWA

My problem is that data from this server is in EPSG:4326 projection, when d3js is using U.S.-centric (d3.geo.albersUsa). I can convert GML to shapefile (using QGIS) and then to TopoJSON or GeoJSON (using http://www.mapshaper.org/), but I need to know what projection I must use to display my map correctly.

3
  • intresting library, while i was googling found this github.com/d3/d3-geo-projection (extension) and this github.com/mbostock/d3/wiki/Geo-Projections. This one gives impression that d3 understand Wgs84 smartjava.org/content/using-d3js-visualize-gis keyword: d3.geo.mercator() , that should be projection for incoming data, after that you do transformation to desired projection and show data (disclaimer: newer used d3 , and i dont do js) Jan 8, 2014 at 14:17
  • @simplexio thanks for tip :) I'm more js guy than GIS, so this whole projection is new to me. I can use ogr2ogr to convert projections, but I don't know which one would be best for Poland
    – Misiu
    Jan 8, 2014 at 14:27
  • Using srid:3857 (google) or 4326 (wgs84) are easy because most of data will be in one of those. If you want to calculate length in meters use 3857 if that is not important use 4326. If you want to be really accurate measurements use some local polish(?) system. i don't know any good one. One thing about projections is that every projection has its own perks, some of them distorts angle or distance or area, so you need choose one depending your use. only data visualization you can use pretty much anything you want Jan 8, 2014 at 14:41

1 Answer 1

2

I would suggest Albers equal-area conic as in this example for the UK and adjust the parameters for Poland.

First generate your topojson from the GML file with the following two commands (note that the the geographic coordinates in gml are swapped, so we need to tell ogr2ogr swap them back with the --config options):

ogr2ogr -f "GeoJSON" --config GML_INVERT_AXIS_ORDER_IF_LAT_LONG YES --config GML_CONSIDER_EPSG_AS_URN YES poland.json poland.gml
topojson -o pl.json poland.json

For Poland you want to set the standard parallels to something like 48°N and 56°N, rotate longitude by -19° and set the center to 0°W 52°N.

The complete code is:

<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>

<script>
var width = 600,
    height = 600;

var projection = d3.geo.albers()
    .center([0, 52])
    .rotate([-19, 0])
    .parallels([48, 56])
    .scale(5000)
    .translate([width / 2, height / 2]);

var path = d3.geo.path()
    .projection(projection);

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);

d3.json("pl.json", function(error, pl) {
  svg.append("path")
      .datum(topojson.feature(pl, pl.objects.poland))
      .attr("d", path)
      .attr("fill", "#eee");
});
</script>

enter image description here

1
  • this is exactly what I created :) But I didn't have to swap coordinates. I did simple conversion to TopoJSON and used mapshaper.org to simpify and minimize my files. Thanks for correct coordinates, I was trying to figure them out, but Yours are perfect :)
    – Misiu
    Jan 11, 2014 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.