mbloch / mapshaper

Tools for editing Shapefile, GeoJSON, TopoJSON and CSV files
http://mapshaper.org
Other
3.74k stars 532 forks source link

Questions about -merge-layers #580

Closed eric-g-97477 closed 1 year ago

eric-g-97477 commented 1 year ago

Let's say I have the following data:

(test.geo.json)

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [-170, 45],
            [-160, 45],
            [-160, 30],
            [-170, 30],
            [-170, 45]
          ]
        ]
      },
      "properties": {
        "id": "a"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [-150, 45],
            [-140, 45],
            [-140, 30],
            [-150, 30],
            [-150, 45]
          ]
        ]
      },
      "properties": {
         "id": "b"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [-130, 45],
            [-120, 45],
            [-120, 30],
            [-130, 30],
            [-130, 45]
          ]
        ]
      },
      "properties": {
         "id": "c"
      }
    }
  ]
}

And I wanted to merge polygons a & b together.

I tried doing:

mapshaper test.geo.json -merge-layers target=a,b -o test_2.geo.json

but I get the error Error: Missing layers: a,b.

Also, is it possible to merge a & b by creating an enclosing polygon? i.e. the a & b features would disappear and be replaced by:

    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [-170, 45],
            [-140, 45],
            [-140, 30],
            [-170, 30],
            [-170, 45]
          ]
        ]
      },
      "properties": {
         "id": "???"
      }
    },

If that is possible, then assume I wanted to merge a & c with an enclosing polygon, but only if there way no overlap with another polygon. In this case, attempting to merge a & c would overlap with b and the merge would not happen.

One other random question...is it possible to extrude features? For example, let's say I wanted to extrude a by some positive factor X in all directions so it became bigger. I would not want an overlap with other features to be created, so the extrusion procedure would not grow the feature where that would happen.

eric-g-97477 commented 1 year ago

never mind. I am looking for the dissolve feature.