Using a shapefile from Natural earth, I am trying create a map of Europe with d3-geo’s new command-line interface. The following:

shp2json -n ne_50m_admin_0_countries/ne_50m_admin_0_countries.shp \
| ndjson-filter '["ALB", "AND", "AUT", "BEL", "BGR", "BIH", "BLR", "CHE", "CYP", "CZE", "DEU", "DNK", "ESP", "EST", "FIN", "FRA", "FRO", "GBR", "GIB", "GRC", "HRV", "HUN", "IMN", "IRL", "ISL", "ITA", "LIE", "LTU", "LUX", "LVA", "MCO", "MDA", "MDA", "MKD", "MLT", "MNE", "NLD", "NOR", "POL", "PRT", "ROU", "SMR", "SRB", "SVK", "SVN", "SWE", "UKR", "VAT", "XKX"].includes(d.properties.adm0_a3)' \
| ndjson-reduce \
| ndjson-map '{type: "FeatureCollection", features: d}' \
| geoproject 'd3.geoConicEqualArea().parallels([43, 62]).rotate([0, 0]).fitSize([960, 960], d)' \
| geo2svg -w 960 -h 960 \
> europe.svg

...creates this output:

enter image description here

How can I remove all the overseas territories (e.g. French Guyana) and distant islands, so I'm left with a map of just 'mainland' Europe? Nothing west of Portugal, nothing south of mainland Spain etc. More like this:

enter image description here

3 Answers 3


I'd bring it into QGIS and use Vector > Geometry > Multipart to Singlepart.

In Natural Earth, France is a multipolygon so it is one feature with lots of individual polygons (France, French Guiana, Reunion etc).

Doing this breaks each of these polygons into its own feature - so your shapefile jumps in size from ~250 (roughly one feature per 'country') to several thousand features.

Then select the ones you want with the select tool, dragging your selection over the region of Europe you want, and save as a new shapefile (making sure you check "save selected features only")

You should now be able to plug in the new shapefile into your first line of code and it should work.


If you want to keep it all command line, you could use ogr2ogr's clipsrc option to clip your shapefile to a bounding box before sending it through the d3-geo tools.

I ran:

ogr2ogr -f "ESRI Shapefile" -clipsrc -25 34 35 73 europe-clipped.shp ne_50m_admin_0_countries.shp

The values for -clipsrc were sussed out using projectionwizard.org. Then used your commands to get: Europe clipped

europe-clipped.svg as a gist.


QGIS can do this without external programs.

  1. Follow the answer above: Vector > Geometry > Multipart to Singlepart.
  2. Follow this very helpful Video answer on clipping, watch to the very end: Custom Clipping in QGIS
  3. Once clipped, reverse the first step: Vector > Geometry > Singlepart to Multipart. This preserves any data fields that you had before step 1.

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.