Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to add a GeoTransform? #5

Closed
rveciana opened this issue Apr 7, 2017 · 4 comments
Closed

Is it possible to add a GeoTransform? #5

rveciana opened this issue Apr 7, 2017 · 4 comments

Comments

@rveciana
Copy link

rveciana commented Apr 7, 2017

I made a similar (worse) library some months ago: https://github.com/rveciana/raster-marching-squares
I don't find how to give d3-contour the geographical positions for the pixels, so it's possible to project the output isolines.
In GDAL they call it GeoTransform, which is simply the coordinates of the first pixel and the delta for each position in the x and y directions.
If a geotransform could be set, the output coordinates would be in lon/lat and a projected geo-path could be used.
An example using my old library and reading the data from a GeoTiff: http://bl.ocks.org/rveciana/bef48021e38a77a520109d2088bff9eb

@mbostock
Copy link
Member

mbostock commented Apr 7, 2017

There are a lot of options for displaying GeoJSON while applying simple transformations in planar coordinates:

  1. Use the SVG viewBox attribute.

  2. Use SVG transforms.

  3. Use Canvas transforms.

  4. Use d3.geoPath’s projection, often in conjunction with d3.geoIdentity.

Here’s a live example of the surface temperature GeoTIFF using the first option:

https://bl.ocks.org/mbostock/4886c227038510f1c103ce305bef6fcc

If you want to convert from planar coordinates back to spherical coordinates, and then reproject those spherical coordinates using a different spherical-to-planar projection (say d3.geoOrthographic), it’s a bit tricker. You could either assume that the planar coordinates are equirectangular (d3.geoEquirectangular) and then treat them as x = longitude, y = latitude (perhaps with another simpler planar translate and scale), or you’d need to know the exact spherical projection in use and run it through project.invert. After that, you’d want to run it through d3.geoStitch to remove the antimeridian and polar cuts, and lastly run back through your new projection.

@rveciana
Copy link
Author

rveciana commented Apr 7, 2017

Thank you! It's very simple, a very nice library.

@rveciana rveciana closed this as completed Apr 7, 2017
@mbostock
Copy link
Member

mbostock commented Apr 7, 2017

Here’s an example of reprojecting contours:

preview

@Plantain
Copy link

Plantain commented May 3, 2017

Could you add an example for reprojecting contours when the source is a limited domain rather than 0,360 -90,90?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants