Search code examples
gisgeojson

Map Data in JSON format. Easily edit a selection of vertices


I have the Spanish provinces polygons in a JSON file. For one province, the schema looks like this:

{
    "geometry":
    {
        "type": "MultiPolygon",
        "coordinates":
        [[[
           [-7702,-4944],
           [-7678,-4979],
           [...,...],
           [-5967,-4077],
           [-5982,-4097]
        ]]]
    },
    "type": "Feature",
    "properties":
    {
        "labelrank": 20,
        "code_hasc": "ES.CN",
        ...
        "type": "Comunidad Autónoma",
        "id": "ES.CN"
    }
}

I would like to move the vertices of some provinces as described in the image below. The reason for that is that the visualization looks terrible if I project as it is defined in the JSON (half of the map is just empty space). I want to move the Canary Islands up there

Using mapshaper.org I was able to identify the coordinates where I should send the most northern vertex. From here it just a matter of addition to each vertex in all polygons. Before I create a script in Python to do that, I would like to ask the community if there is a software or tool that allows me to select all desired vertices and move them to the desired position, something like moving a selection of nodes using Adobe Illustrator or AutoCad.


Solution

  • Ian Turton kindly recommended using QGis for that purpose. The use of the tool is quite straightforward for doing this kind of batch polygon displacements:

    1. Open the json file with your geodata
    2. In the Attributes toolbar, click on "Select features" select features icon
    3. Select the features that you want to move: selecting features
    4. In the Vector Toolbar, click on "Toogle editing" toogle editing icon
    5. Eventually you may need to display the Advanced Digitizing Toolbar. Right click on any toolbar and select "Advanced Digitizing Toolbar" under Toolbars advanced digitizing toolbar
    6. With your feature still selected, click on the "Move Feature" icon move feature icon
    7. Click on your selected features and move to your desired location features in their new positions

    Because I just wanted the new polygon coordinates for the Canary Islands, I exported the features as GeoJson and replaced accordingly.