Monday 22 May 2017

geojson - Remove some islands from Europe json file


It's the first time I use a JSON file to create a map of Europe. I downloaded these two files:



The first represents the states, while the second represents the regions of each state. I use them both because when you click on a country, the map is zoomed and I show the regions of the chosen state.


What I would like to do now is remove some islands that do not interest me (those circled in red). enter image description here


How can I do that? Of course I want to remove them from both nuts0.json and nuts2.json.




UPDATE


These are the regions I would like to delete:


enter image description here



I was thinking of using mapshaper because it's online and it seems simple, but I can use any software to let me do what I want.


I didn't try to do anything because I don't know how to do, the only idea that comes to me is to edit the file by hand but this thing does not seem particularly intelligent, because I don't know how to change the arcs.


I would like to delete those circled. I have read somewhere that it is possible to establish a threshold, and to eliminate the smaller regions of this threshold. But there are regions (see Sardinia) that I care to keep and Sardinia is certainly smaller than the French Guaiana.



Answer



So here is one solution using QGIS 2.18:


1) Save GeoJSON from URL and open in QGIS
2) Run "Multipart to singlepart" on the GeoJSON
3) Select desired polygons
4) Export selection to a new GeoJSON Layer


Details:



Step 1: Save and download the GeoJSON layer from the URL (copy paste the data into a text editor and save as "nuts0.json"). Drag this file into QGIS and select OK to accept the CRS (EPSG 4647).


Step 2: Notice that after saving a new layer has been added to the Layers Panel. Select from the Processing Toolbox (press CTRL+Alt+T, if you don't see it) the algorithm Multipart to Singlepart and run it on the nuts0 GeoJSON:


enter image description here


Step 3: In the Layers panel, highlight the 'Single Parts' layer that was generated from the algorithm, and in the toolbar above click on Select Features by area or single click -> Select features by polygon:


enter image description here


Select the polygons (countries) that you want to keep and they will turn yellow. Zoom in to verify the result:


enter image description here


Step 4: Right-click the created "Single parts" layer in the Layers Panel and click "Save as" (same as in step 1), only this time make sure to Check "Save only selected features", and make sure the format is GeoJSON. Repeat the steps for the other GeoJSON (nuts2.json).


enter image description here Result:


enter image description here



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...