question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I think there is a bug with multipolygon shapes, I started from example/test_multiple_poly.js Open the generated shape in qgis you will see that there is a problem… Is there something wrong in my code ?

var write = require('shp-write').write,
    fs = require('fs');

var features = [];
var points = [];
for (var i=0; i<3; i++) {
  features.push({id: i});
  points.push([[i, 0], [i, 1], [i+1, 1], [i+1, 0], [i, 0]]);
};

console.log(features);
console.log(points);

function finish(err, files) {
    fs.writeFileSync('polygon.shp', toBuffer(files.shp.buffer));
    fs.writeFileSync('polygon.shx', toBuffer(files.shx.buffer));
    fs.writeFileSync('polygon.dbf', toBuffer(files.dbf.buffer));
    fs.writeFileSync('polygon.prj', files.prj);
}

function toBuffer(ab) {
    var buffer = new Buffer(ab.byteLength),
        view = new Uint8Array(ab);
    for (var i = 0; i < buffer.length; ++i) { buffer[i] = view[i]; }
    return buffer;
}

write(
    // feature data
    features,
    // geometry type
    'POLYGON',
    // geometries
    points,
    finish);

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
christophemacabiaucommented, Jul 7, 2017
1reaction
gxcodescommented, Jun 14, 2017

Thanks for the link, will definitely check it out. Hopefully it doesn’t need any native dependencies as I’m developing a multi-platform app with electron.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error validating geometry collection / multipolygon in PostGIS
I have just updated a table of polygons with a query which returned: UPDATE parcel SET wkb_geometry = ST_Multi(wkb_geometry) UPDATE 399212 Query ...
Read more >
Bug report #7555: Postgis Multipolygon Errors
Severe known bugs when using merge or clip tools that create POLYGON and not MULTIPOLYGON. Related issues. Duplicates QGIS Application - Bug report...
Read more >
Invalid MultiPolygon value even though all the Polygons are ...
I am trying to convert coordinates to WKT format. Here I have a list of polygons which should be identified as a Multi...
Read more >
Possible bug plotting MultiPolygons in scattermapbox?
In scattermapbox it seems to be only plotting the outer lines and filling in the entire polygon, compared to the plot on github...
Read more >
ERROR: Geometry type (MultiPolygon) does not match ...
Warning 1: Geometry to be inserted is of type 3D Multi Polygon, whereas the layer geometry type is 3D Polygon. Insertion is likely...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found