How to set the extent for graticules on maps of smaller areas?

Working Notebook: Experiments with maps / Saneef H. Ansari / Observable

I’m trying to draw maps of smaller regions (like country, state, district). Since it is for smaller regions, I have to reach for projections like geoTransverseMercator. I need to draw graticules and add graticule labels (which is a problem for another day).

I can use d3.geoGraticule() without setting extent (graticule.extent()) and use clip path. But ends up with huge SVG files.

I tried with graticule.extent(), but the lines are not extending to the edges. What is the right way to set the extent for the graticules?

Have you tried setting the projection’s extent before drawing the graticules:

projection.clipExtent([[0,0], [width, height]])

1 Like

Thanks @Fil! That solves my problem!