This example demonstrates how to use d3.geoIdentity to clip a polygon to an extent while rendering. You can save the resulting clipped polygon using d3.geoProject.