mapshaper | Tools for editing Shapefile , GeoJSON , TopoJSON and CSV files | Map library

 by   mbloch JavaScript Version: 0.6.59 License: Non-SPDX

kandi X-RAY | mapshaper Summary

kandi X-RAY | mapshaper Summary

mapshaper is a JavaScript library typically used in Geo, Map applications. mapshaper has no bugs, it has no vulnerabilities and it has medium support. However mapshaper has a Non-SPDX License. You can install using 'npm i mapshaper-with-patch' or download it from GitHub, npm.

Mapshaper is software for editing Shapefile, GeoJSON, TopoJSON, CSV and several other data formats, written in JavaScript. Mapshaper supports essential map making tasks like simplifying shapes, editing attribute data, clipping, erasing, dissolving, filtering and more. See the project wiki for documentation on how to use mapshaper. To suggest improvements, add an issue.

            kandi-support Support

              mapshaper has a medium active ecosystem.
              It has 3313 star(s) with 497 fork(s). There are 126 watchers for this library.
              There were 10 major release(s) in the last 6 months.
              There are 106 open issues and 447 have been closed. On average issues are closed in 122 days. There are 7 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of mapshaper is 0.6.59

            kandi-Quality Quality

              mapshaper has 0 bugs and 0 code smells.

            kandi-Security Security

              mapshaper has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              mapshaper code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              mapshaper has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              mapshaper releases are available to install and integrate.
              Deployable package is available in npm.
              Installation instructions, examples and code snippets are available.
              It has 1324 lines of code, 0 functions and 563 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of mapshaper
            Get all kandi verified functions for this library.

            mapshaper Key Features

            No Key Features are available at this moment for mapshaper.

            mapshaper Examples and Code Snippets

            No Code Snippets are available at this moment for mapshaper.

            Community Discussions


            Simplifying a GeoJson FeatureCollection using mapshaper causes issues
            Asked 2022-Mar-29 at 20:09

            More specifically, it causes the same code to render an outline on the map, and only recognizes the last path element when using pointer events. I simplified a continents.json file on mapshaper using their website and replaced the file in my public/data folder. Currently I'm fetching the data in one component and passing it down to another.



            Answered 2022-Mar-29 at 20:09

            After trying out a lot of different simplify options I feel silly. All you have to do is add the gj2008 option to the output command.



            Interactive farm maps
            Asked 2021-Dec-02 at 12:40

            In my use case I need to create interactive farm maps where I can select fields. I'm trying to do this using the react-simple-maps component.

            what was done

            I created the farm Shapfile map in QGIS. Converted to TopoJSON using Mapshaper as per this tutorial.

            However the map does not render correctly, see CodeSandbox.

            What can I be missing?

            Is this the best component to use in this case?

            Map error

            TopoJSON Map



            Answered 2021-Dec-02 at 12:40

            I managed to solve it, the problem was in the project's SRC configuration, it was UTM and the correct is WGS 84, I changed, exported in GeoJSON format and converted to TopoJSON using Mapshaper, changed the projections and rotation and now everything is ok as you can see in CodeSandbox.



            Power BI shape map is lagging/not working
            Asked 2021-Apr-30 at 08:50

            I want to build a shape map in Power BI using postal area for Australia. I downloaded the Correspondence, 2011 Postal Area to 2016 Postal Area and converted it to json file type on mapshaper.

            My data has a postcode column that looks like this:

            and the map keys looks to be of the same format:

            However, when I tried to plot the shape map by sales column (the value column), output looks like this

            which doesn't zoom in. Is it because the data is too large? But there are only 300 rows in the table. How can I map out the areas by postcode?



            Answered 2021-Apr-30 at 08:50

            No wonder your map loads slowly. You should simplify the map using Mapshaper. Start with that. There could be another cause of the slowness in your measure you put on the map color saturation. Start with the simplest possible measure such as SUM( Table[no of kangaroos] ), avoid SUMX or IF in that measure. You could use Daxstudio to check the performance of the measure.



            How to plot longitude latitude coordinates for geoAlbersUsa() projection?
            Asked 2021-Jan-03 at 20:29

            I am trying to create a simple bubblemap that plots longitude-latitude pairs by a number of admissions for a county using US DHS data. My CSV file has the name of county, longitude, latitude, type of Admission, class of admission, number of admissions, and country of origin. I've created some checkboxes that will allow the user to see a bubblemap of the different classes of admissions that were admitted to the United States.

            I've learned that the d3geoAlbersUsa projection projects the map of the USA at [0,0] which is off the coast of Africa. From the photo below (see Imgur link), you can see that my points seem to plot at the correct coordinates. However, the background map is not visible. When I use d3.geoMercator() and center the projection on [0,0] I see the map. In both cases, I don't know how to make the bubbles appear on the map.

            I'm new to d3 so I'm not sure how to go about this. How do I create a bubblemap using long lat coordinates with the d3geoAlbersUsa projection? Thanks for the help.

            Here is my index.html:



            Answered 2021-Jan-03 at 07:07

            D3 projections are all pretty similar. If one projection projects a given point correctly, chances are so does every other one. They take coordinates in decimal degrees and spit out coordinates in pixels and not much else. Consequently, your statement: "d3geoAlbersUsa projection projects the map of the USA at [0,0] which is off the coast of Africa." is incorrect. [0,0] in degrees is off the coast of Africa, [0,0] in pixels can be anywhere. D3 is giving you pixels, not degrees.

            If you have features/tiles/raster that show Africa where the US is or vice versa, you have conflicting projections or coordinate systems, not a failure of d3.geoAlbersUsa.

            Also, if you are mixing pre-projected geometry and unprojected geometry, you're making it too difficult: you'll need to ensure that the projections used to pre-project one geometry matches the projection used to project the second, which unless you use d3 to preproject the geometry offline somewhere will cause you some headaches.

            If you have a csv with coordinates in decimal degrees and a geojson with the same, you can assume that the projection (and consequently, any paths) will be rendered consistently, and correctly (where correctly is not necessarily equivalent to as desired...).

            Now d3.geoAlbersUsa is a bit of a special projection in that it is a composite projection combining several distinct projections (all Albers, while also shrinking Alaska down several times). It is calibrated to be centered on the US assuming a screen size of 960x600 pixels. You shouldn't need to alter the centering point, it has been set for you. The translate must be modified in your case, however, as this translates the projected coordinates. The default translate expects a container of 960x600 pixels. You want the translate to be equal to width/2,height/2, as you have. Trickier is the scale, the default scale is 1070, which extends the US across 960 pixels. This scale factor is linear, so we can use: 1070/960*width to create a new scale factor (assuming width is the limiting factor).

            d3.geoMercator is more plain, but we need to center that projection properly because it isn't by default centered on the US. We can use:



            Cannot Transform GeoJSON to TopoJOSN
            Asked 2020-Oct-29 at 16:22

            I am trying to transform GeoJSON to TopoJOSN in order to put into Vega-Lite. Therefore I can draw a map.

            I used to download the .json for map Oceania (Low resolution), then I put this file into so that I can export it again as .topojson

            However, even I choose export as .topojson, the file still give me .json. Because when I put this URL to Vega-Late, it cannot display a Oceania map. (My code at the very bottom of the question)

            Anyone know how can I transform into topojson? Or even maybe there is anything wrong with my URL?



            Answered 2020-Oct-15 at 14:04

            A couple issues with your specification:

            • your GeoJSON file does not include a feature named "states". It includes a feature named "custom".
            • you are using the albersusa projection, which only shows the USA, and your GeoJSON has no data within this boundary.

            Fixing these issues, and using an orthographic projection centered on Australia, gives you a better chart (view in editor):



            D3 V6 - Zoom and Drag Functionality
            Asked 2020-Oct-12 at 16:28

            Creating a world map Choropleth with D3 v6 in Angular 7. (trimmed down from Angular into plain JavaScript)

            Shape files gathered from NaturalEarth and compiled in mapshaper to create GeoJSON.

            Keeping it simple with just countries but I am getting a rubber band effect. When I try to drag the map (whether it be the background or on a specific country), it will try to move where you are dragging but then pop back to it's original position unless you drag your cursor across the screen or quickly release after an event is triggered.

            As well, when you zoom in on a specific country and then zoom/drag on a different country, it pops you back to the original zoom when the map is created.



            Answered 2020-Oct-12 at 16:28

            Just use d3-zoom for both zooming and panning. Removing drag and zoom from the countries itself fixed it.



            How to correctly create a Polygon into a shapefile with Java?
            Asked 2020-Oct-06 at 12:42

            I am trying to create shape files from a list of coordinates and it looks like it works but when I'm trying to view the shapefile in a shapefile viewer, it looks like there's no coordinates in my shape. Also if I then download my shapefile as geoJSON it looks empty like this: {"type":"GeometryCollection", "geometries": []}

            So I have this one Java class, where I first create some dummy data, then create a Polygon SimpleFeatureType and then convert my list of points into a polygon and eventually try to write that polygon into a shapefile. I dont get any errors and all looks like running smoothly until I try to view it in the browser.

            Here's my class with some debug prints :



            Answered 2020-Oct-05 at 16:14

            Whenever I see something with an transaction where data is not written, I look at the transaction handling. You make it actually good, as you rollback when there is an exception. But I would strongly suggest that you also make some log message indicating what kind of exception occured. Especially as you catch the generic Exception.

            See the catch block:



            Cannot add capitals to geojson world map
            Asked 2020-Sep-08 at 10:40

            I am using d3 to render a world map with clickable countries. The countries are from a geojson file, and I have no problems loading a particular continent, region or the entire world, using this site:

            However, the data from that site does not have any capitals in their geojson files. So instead I looked at, which clearly shows that one should be able to render a region with cities on it. I take their files and convert them to geojson via, but for some reason I ONLY get cities, as single dots against a blank background. There is not a single map I can find which provides a map of countries with capitals/cities inside country borders.

            This leads me to wonder whether I am somehow supposed to combine a geojson file of countries with a geojson file of capitals, and render one on top of the other. In that case, how is that possible? Or is there some other solution? I attach the code where I render my world map (which works fine):



            Answered 2020-Sep-08 at 10:40

            I have a solution now, posting it here in case it helps anyone else:



            An existing vega-lite map suddenly seems very zoomed-in - what is happening?
            Asked 2020-Sep-04 at 08:03

            I have a map with an older topojson format that once worked with Vega-Lite. Now we only see a purple square in this editor gist.

            I've rebuilt the map with the same code but updated topojson in the vega editor and saved as a gist here.

            With the new vega release, it seems like I need my topojson files to be formatted differently, with the arcs first, like the export output. Why is this? It's broken several existing web maps, and took me a few hours to figure out. Seems like I can fix it with a workflow change, but I am curious.



            Answered 2020-Sep-04 at 08:03

            Topojson data follows the left-hand rule for projected data (clockwise orientation for outer rings and counter- clockwise for interior rings), where the data in your topojson file is structured according the right-hand rule (counter-clockwise for outer rings and clockwise for interior rings). The order of your polygons seems negligible, but it defines which part is ‘inside’ and ‘outside’ the polgygons.

            You can do two things:

            1. Do not use a geographic projection, but the cartesian-like identity projection.
            2. Force your source data into the right order.

            Example for 1:

            "projection": {"type": "identity", "reflectY": true},

            see Vega Editor

            Example for 2:

            Use MapShaper or Python to force your data in the right order. Here an example using Python



            How to use a custom JSON map in Highmaps
            Asked 2020-Jul-06 at 10:58

            I would like to use a custom world map with Highmaps. I used mapshaper (great tool!) to reduce the number of vertices, and checked the JSON code with a JSON validator and imported it in QGIS, where it works fine. But I don't succeed in convincing Highmaps to use it:

            I use:



            Answered 2020-Jul-06 at 10:58
            1. You need to assign your JSON object as'name'), where name is a value which we will use to the import.

            2. Highcharts has the option joinBy set to hc-key by default. I can't see this property in your JSON, so we need to change this value, let's say to:


            Community Discussions, Code Snippets contain sources that include Stack Exchange Network


            No vulnerabilities reported

            Install mapshaper

            With Node installed, you can install the latest release version of mapshaper using npm. Install with the "-g" flag to make the executable scripts available systemwide.


            rmapshaper is an R package written by Andy Teucher that gives R users access to many of mapshaper's editing commands. Here are resources for using mapshaper with Docker, provided by Christian Weiss. You can find a number of mapshaper tutorials online, including a two part guide to command line cartography by Dylan Moriarty and this introduction by Jack Dougherty.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
          • npm

            npm i mapshaper

          • CLONE
          • HTTPS


          • CLI

            gh repo clone mbloch/mapshaper

          • sshUrl


          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link