问题
So I've created a clipped and reprojected raster image from a Natural Earth 2 data set. It is simple enough to set that as a base layer and project a vector layer on top of it. The problem I'm having is properly scaling the images so they align perfectly.
Please refer to this block for the example: http://bl.ocks.org/mkessy/8545864
Here is what I've done so far: Use gdalwarp to reproject the raster to Albers Equal Area and clip to the bounding box of North Dakota, output the image to my desired resolution (960 x 500) In D3 I use the exact same projection and overlay the vector onto the raster Now how do I go about adjusting the scale so that it properly aligns the 2 layers? I'm thinking it may do with the resolution of the original raster, perhaps I've distorted it by resizing? I know how to automatically compute scale based off the bounding box but it still doesn't fit the raster layer. I've looked at several examples and cannot figure out how the author computed the scales: see Costa Rica and the New York Times Border Graphic, 3/2/2013) (can't post link). In both cases the scale parameter passed to the d3.geo object is a magic integer as far as I can tell.
来源:https://stackoverflow.com/questions/21373149/properly-scale-a-vector-to-fit-a-raster-layer