Geographic Information Systems Asked on August 8, 2021
I am trying to load a module called ‘geojson2h3’ in my NodeJS
app. After running npm install geojson2h3
, I tried following the initial code instructions given in Github
to test it out:
import geojson2h3 from 'geojson2h3';
const polygon = {
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: [
[
[-122.47485823276713, 37.85878356045377],
[-122.47504834087829, 37.86196795698972],
[-122.47845104316997, 37.86010614563313],
[-122.47485823276713, 37.85878356045377]
]
]
}
};
const hexagons = geojson2h3.featureToH3Set(polygon, 10);
// -> ['8a2830855047fff', '8a2830855077fff', '8a283085505ffff', '8a283085506ffff']
const feature = geojson2h3.h3SetToFeature(hexagons);
// -> {type: 'Feature', properties: {}, geometry: {type: 'Polygon', coordinates: [...]}}
This method throws a SyntaxError: Cannot use import statement outside a module
error. I then tried using the NodeJS require
method as such: const geojson2h3 = require('geojson2h3');
, replacing the import
statement. This throws an Uncaught Error: undefinedModule
error. The package shows in my package.json
file, but I don’t see it in my node_modules
folder. I am assuming that’s related to the issue. What did I do wrong here?
*Note: I know that this is a GIS-related package but the issue is a generic NodeJS package issue, not a GIS-specific one.
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP