mbloch / mapshaper Goto Github PK
View Code? Open in Web Editor NEWTools for editing Shapefile, GeoJSON, TopoJSON and CSV files
Home Page: http://mapshaper.org
License: Other
Tools for editing Shapefile, GeoJSON, TopoJSON and CSV files
Home Page: http://mapshaper.org
License: Other
I've got a huge shapefile that was too large to use on mapshaper.org. But I installed mapshaper locally, and made a happy, pretty, generalized file. However, all the attribute data is missing from it... that was originally in the map.dbf file.
I figured I could join it back in.... but the output shapefile FID doesn't match any of the input dbf fields.
Why am I losing all the attribute data? (The fields don't appear in the geojson or shapefile output). What do you recommend so that I can keep key data in the output file?
After some debugging, what appears to be happening is that I'm simplifying a shape to resolution that is only a little bit smaller than it's width and height. This causes MapShaper.getAverageSegment
, when called by calcStripeCount
, to return NaN
which percolates back and messes up all sorts of calculations in findSegmentIntersections
and causes the while (true)
loops to never break.
I've created a gist with a test case that reproduces this behavior.
Similar to the original Flash-based mapshaper web app
I'm trying to simplify adimistrative areas of switzerland and then merge low-level areas with higher level areas with ogr2ogr. But in some cases, the simplification procudes self intersecting polygons. If this happens, ogr2ogr and also the dissolve tool of QGIS is not able to merge the polygons together.
So, it would be cool to prevent this from happening somehow.
An example:
Hi,
When I try to load a large shapefile (500 MB) I am getting following error in the console:
SCRIPT5022: BinArray constructor takes an integer, ArrayBuffer or Buffer argument
mapshaper.js, line 446 character 3
The name of the file is: all_Merge.shp
QGIS and ArcMap are doing fine with opening this file. I realise the file is very big and complicated, so perhaps I am hitting the processing limit of your tool? In such a case I would most appreciate a suggestion which offline tool (ArcMap, QGIS, ogr2ogr) does as good job as your script.
If you like I can share with you my shapefile.
Cheers,
Lucas
The commandline tool is no longer able to regenerate the original .shp file after topology processing.
Testing with a set of snippets from Shapefiles that isolate particular problems and toy files
GeoJSON (and TopoJSON) files that are not wgs84 should have a crs
property.
When converting *JSON to Shapefile, a .prj file should be generated.
Hi,
I have some troubles running the latest version.
I had no problem with a later fetch, that was from July 27th (commit 309baa8).
With the latest code I get:
user@host:~$ node /home/user/mapshaper/bin/mapshaper -i 1222 /home/user/shapes/MyShape.shp --dp -o /home/user/shapes/MyShapeSimplified.shp
module.js:340
throw err;
^
Error: Cannot find module 'optimist'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/peroper/mapshaper/bin/mapshaper:22:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
I don't really have the time nor competence to look where the problem comes from, so I register this issue in case someone else has the problem with the latest code base.
Regards,
Thibault D.
I have not seen this reported, so you might be unaware of this. Currently, if I import this file, for example, I get this:
Just tested out the MapShaper TopoJSON export. It appears that null geometries (after simplification) are reported as nulls. However, per the specification, null geometries in TopoJSON are represented as {type: null}
. That is, you can have an id and properties on a TopoJSON geometry, and the geometry is null if the type is null, not if the object itself is null.
For example, MapShaper currently exports a Topology like so:
{
"type": "Topology",
"transform": โฆ,
"arcs": โฆ,
"objects": {
"counties": {
"type": "GeometryCollection",
"geometries": [
{"id": 0, "type": "MultiPolygon", "properties": โฆ, "coordinates": โฆ},
{"id": 1, "type": "Polygon", "properties": โฆ, "coordinates": โฆ},
null,
{"id": 3, "type": "MultiPolygon", "properties": โฆ, "coordinates": โฆ},
โฆ
]
}
}
}
The expected output is:
{
"type": "Topology",
"transform": โฆ,
"arcs": โฆ,
"objects": {
"counties": {
"type": "GeometryCollection",
"geometries": [
{"id": 0, "type": "MultiPolygon", "properties": โฆ, "coordinates": โฆ},
{"id": 1, "type": "Polygon", "properties": โฆ, "coordinates": โฆ},
{"id": 2, "type": null, "properties": โฆ},
{"id": 3, "type": "MultiPolygon", "properties": โฆ, "coordinates": โฆ},
โฆ
]
}
}
}
Running mapshaper under Ubuntu 13.10 results in the following error:
/usr/bin/env: node --nouse_idle_notification --expose_gc: No such file or directory
This is caused by the shebang line in mapshaper
:
#!/usr/bin/env node --nouse_idle_notification --expose_gc
Everything after the first white space is passed as one command to env
. See http://stackoverflow.com/questions/4303128/how-to-use-multiple-arguments-with-a-shebang-i-e . According to that answer there is no portable way to pass arguments.
It's missing the simplifyPaths()
function because it doesn't have the latest code from mapshaper-simplify.js.
I didn't send a pull request because a node build
fixes it right up.
Seems like this could be a bit of an ongoing problem: It's pretty easy to forget to build the file. I wonder if it would be a good idea to add a pre-commit hook to build mapshaper.js automatically?
This would be useful for reducing the size of geojson files that are originally in high resolution but only a low resolution is required. The problem with reducing the precision on import is that it creates too many overlapping features particularly where there are lots of small features, which can create invalid geometry. Not sure what the issues are or how hard it is to implement, I just know that I would find this extremely useful
Once we're working on a file in the GUI, there's no feedback to remind us which file we loaded.
Then, if we drag a DBF file (to ensure that that data is included), there's a plus icon for a moment, but then any feedback disappears. (We may hardly see the plus icon if we're on a laptop, where the Finder (or file directory window) is on top of the browser when we drag the file. Sometimes I'm not sure if the file actually arrived.)
(This is related to the feature request #33 )
Alas, I got this message:
Error: [dissolve] deep recursion -- unhandled topology problem
What do you recommend to fix an unhandled topology problem? I can see the red dots in the GUI, but I don't know what to do about them.
I guess I can go into QGIS, and try to figure it out from there, but I wonder if there's a recommended way to go about fixing this situation.
Margie
Can you clarify in:
https://github.com/mbloch/mapshaper/wiki/Command-Reference
for:
"Fields to use as local and foreign keys, separated by a comma."
which field is local, and which is foreign in this example:
mapshaper --join-file demographics.txt --join-keys STATE_FIPS,FIPS:str states.shp
my guess is that:
STATE_FIPS is the local field, and belongs to states.shp, while FIPS:str is the foreign field, belonging to demographics.txt.
Is that correct?
BTW, the examples here:
http://casoilresource.lawr.ucdavis.edu/drupal/node/98
use color in a helpful way, to signal input and output fields. Perhaps a similar strategy could be helpful here.
I look forward to getting to know mapshaper in more detail (and figuring out when to use it, vs. ogr2ogr...)
The goal is to generate multiple data layers from a single low-level dataset. For example, input a layer of counties and export county, state and national boundaries.
I am trying to just import a .SHP file, simplify it and then export as a .SHP file. The export shapefile doesn't seem to work for me, the webpage just hangs. If I export as a GeoJSON or TopoJSON it exports immediately.
New in version 0.2.0: polygon clip and erase commands. These are essential map making operations, but their implementations in GIS software don't always work very well. In ArcGIS, minor topology errors can cause clipping to fail. Also, Arc sometimes will split large files into irregularly-sized rectangular tiles. Clipping in QGIS can be unusably slow.
mapshaper's clip/erase commands are too new to recommend for production use, but they look promising. Here are some anecdotal performance results for the erase command. The polygon data layers come from the National Atlas. Tests were run on a 2012 macbook pro laptop.
Test 1
Target layer:
polbnda_usa.shp (U.S. counties)
WGS 84 / 48.7MB .shp / 3,233 features
Erase layer:
inwatera_usa.shp (Inland water bodies)
WGS 84 / 47.9MB .shp / 26,878 features
Execution time
mapshaper v0.2.1: 15.5 seconds
ArcGIS 10.1: 49 seconds
QGIS 2.2.0: ? (>10 minutes)
Test 2
Target layer:
nationp010g.shp (U.S. national boundaries)
NAD 83 / 7.9MB .shp / 6 features
Erase layer:
wtrbdyp010g.shp (Inland water bodies)
NAD 83 / 47.9MB .shp / 26,878 features
Execution time
mapshaper v0.2.1: 11.5 seconds
ArcGIS 10.1: 112 seconds
QGIS 2.2.0: ? (>10 minutes)
In Test 2, Arc split the output layer into rectangular tiles:
The idea is to add a console so that browser users have access to all of the commands available in the cli.
Mapshaper has added many new command line options in the past month or so, and there's a desperate need for documentation. I've started a project wiki, the Command Reference page is the place to go for detailed information about using the mapshaper
script.
Would be great to have a tool that lists all the field names. Maybe something like:
mapshaper --expression "console.log(FIELD_NAMES)" states.shp
and
mapshaper --expression "console.log(FIELD_NAMES)" states.dbf
and
mapshaper --expression "console.log(FIELD_NAMES)" states.geojson
re: mapshaper --expression "delete ID" states.shp
Is there a way to delete more than one field at a time?
Will this work on geojson files, too? (I'm going to test it to find out).
I get the following error:
mapshaper.js:8662
for (var i=0, n=shape.length; i<n; i++) {
^
TypeError: Cannot read property 'length' of undefined
It's very possible that my shapefile contains errors, I have not enough time and knowledge to fix them at this moment, tough.
I wanted to keep the shapes because the simplification works very well for me, but at the threshold I need (0.05) removes a lot of tiny shapes i still need.
[Error: -p (--pct) option should be in the range (0,1)]
As we make various files, it would be great to have a quick command line for a browser-based viewer. Something like:
bin/mapshaper-gui ../maps/output1/cong133b.json
or
bin/json-viewer ../maps/output1/cong133b.json
which:
In the meantime, what's the fastest way you use to view files? I do have a copy of QGIS open, but just wonder if there's somehow a quicker view option.
Mapshaper doesn't support .dbf files with non-ascii character sets.
Currently you can import .dbf files by dragging them onto the browser window, but you can't convert non-ascii Shapefile data to GeoJSON or TopoJSON. We'll need to support 8-bit encodings and multi-byte encodings like Big5 and UTF-8.
I just encountered a Shapefile in which the outer rings of donut polygons were CCW and the inner rings were CW (the opposite of the correct order). This kind of error could be detected and fixed. Currently CCW rings without CW containing rings get dropped from the output.
Does bin/shpinfo work?
I tried it, and didn't get any results.
(It's currently undocumented, but I was curious.)
Commandline:
mapshaper --keep-shapes --repair -p 0.001 --precision 500 -o shapeQ2.shp shapeQ0.shp
I get the following error:
throw new Error(msg);
^
Error: [findValueByRank()] invalid input
at error (/Users/fabian/dev/feibra-streuplan/SHAPEFILES/mapshaper.git/mapshaper.js:444:9)
at Object.Utils.findValueByRank (/Users/fabian/dev/feibra-streuplan/SHAPEFILES/mapshaper.git/mapshaper.js:3479:53)
at ArcDataset.getThresholdByPct (/Users/fabian/dev/feibra-streuplan/SHAPEFILES/mapshaper.git/mapshaper.js:4833:18)
at ArcDataset.setRetainedPct (/Users/fabian/dev/feibra-streuplan/SHAPEFILES/mapshaper.git/mapshaper.js:4798:22)
at Object.<anonymous> (/Users/fabian/dev/feibra-streuplan/SHAPEFILES/mapshaper.git/bin/mapshaper:29:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)````
Per @mericson
Hi - your tool was amazing in simplifying some geojson data I'm working with. However, the data had some important attributes I needed to keep (country IDs, for example) that were stripped in the simplification process (or import process maybe). Is there a way to preserve that data when simplifying?
For version 0.2.0, I'm considering changing mapshaper's command line syntax. I'd appreciate comments and suggestions.
The current syntax is a jumble of commands, options and values. Here's a typical example:
mapshaper --precision 0.01 --format geojson -p 0.4 --dp --cartesian --dissolve STATE --sum-fields POPULATION --copy-fields STATE_FIPS counties.shp
I'd like to organize the command line arguments into a sequence of commands. Each command is followed by options for that command. In the example below, commands are indicated with a hyphen and the =
sign is used to associate an option's name with a value.
mapshaper -i counties.shp precision=0.1 -simplify dp 4% cartesian -dissolve STATE sum-fields=POPULATION copy-fields=STATE_FIPS -o format=geojson
Often it's possible to apply several transformations at once, but you're limited by mapshaper's fixed order of operations. Plus you have to remember what the order is. I'm proposing to have mapshaper apply transformations in the order that they appear on the command line.
Currently, mapshaper works best when you want to read in a single layer of features and export a modified version of that layer. If you're working with multiple layers (for example, a TopoJSON file containing multiple named objects), there's no way to specify which layer (i.e. object) a command applies to.
You should be able to target a particular layer or set of layers. Here's an example showing how you could import a TopoJSON file containing two polygon layers -- one named "states" and another named "counties" -- and export the shared boundaries of the states layer as a GeoJSON file.
mapshaper -i usa.json -innerlines target=states -o target=states format=geojson
This would create a GeoJSON file named states.json
.
You should be able to save the output of a command to a new layer and retain the original layer. For example, you might want to import a layer of county polygons, create a new layer containing state-level polygons, and save both layers as a single TopoJSON file. There could be an option that means "save the result to a new layer named ___". Maybe something like:
mapshaper -i counties.shp -dissolve add-layer=states STATE_FIPS
An alternative could be to use the "+" symbol to mean "add layer."
Edit: This is the option I went with in v0.2.0-pre. There's an option named no-replace
with +
as an alias. Use the name=
option to give the new layer a name.
mapshaper -i counties.shp -dissolve STATE_FIPS + name=states
Would be nice if after using the mapshaper-gui, we could generate a command line that reflects the same settings that were just applied.
(I'm curious, too, how to reflect the shapefile + dragged-to-GUI dbf, on the command line.)
The docs for usage via the cli are awesome. It would be great to have some docs about how to use mapshaper in other environments
I thought maybe instead of
{"type":"Feature","properties":{"name":"Andorra"},"geometry":null}
You could leave at least one triangle per country (feature)?
Followed the reference of command:
https://github.com/mbloch/mapshaper/wiki/Command-Reference
It seems that -p --pct
and -i --interval
are used to decide the level of the simplify.
However I have some questions:
1 The --pct
It is said "Proportion of removable points to retain". But I think this option is hard to estimate. Since features in the same layer may have different complexity.
2 The -i --interval
I am not exactly sure how does this option work, or how to decide the value of different map scale?
3 The cartesian
"By default, mapshaper simplifies decimal degree coordinates in 3D space"
So what does the "3D space" mean?
If I pass in a dissolve
param, mapshaper will export a file with the dissolve
param as suffix. Example:
mapshaper tabblock2010_25_pophu.shp \
--format shapefile \
--filter "COUNTYFP10 === '025'" \
--dissolve TRACTCE10 \
--sum-fields POP10 \
-o suffolk_tracts.shp
will actually write to suffolk_tracts-TRACTCE10.shp
.
Currently, the minimum complexity of a polygon ring is 3 unique vertices (a triangle).
Tiny triangles aren't particularly desirable on a map. One solution would be to let users specify a minimum of x unique vertices per shape (say, 4, 5, or 6). Island polygons could be removed after the vertex count falls below x. The vertex count of non-removable rings would be prevented from falling below x.
Then again, vertex count is a pretty crude way of determining if a shape is too degenerate or too small to retain.
A better alternative might be to remove shapes whose dimensions are smaller than a certain threshold relative to the intended output size of your map. E.g. if you are making a map to display at 800 pixels wide, islands smaller than, say, two pixels on their longest side could be removed. Or you could use area: islands with areas less than 2 or 3 sq. pixels could be removed.
This solution has its drawbacks too... we can weigh the alternatives if people are interested in this feature.
not really a feature request, but just for your consideration:
I have a very weird issue where several layers within a dataset disappear completely. I dived a little deeper with this one. It seems to only occur if the last and the first coordinates are equal. Not sure why, as this works fine with other sets of data and only some layers are lost.
I played around with all the options always with the same result.
{
"bbox": [13.08834555403396, 52.33824333775998, 13.76114120017369, 52.67546700494284],
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
13.36617949899573, 52.44599246921813],
[
13.36626175602709, 52.44597018162636],
[
13.36640176163547, 52.44611168315112],
[
13.3663763687652, 52.4461183678887],
[
13.367141528691, 52.44649959063752],
[
13.36786961935043, 52.44689492752365],
[
13.3688819301334, 52.44746119242802],
[
13.36899897906896, 52.4475266067027],
[
13.36927934996519, 52.44773186207111],
[
13.36991192585724, 52.44805741528914],
[
13.36993962390992, 52.44807167562743],
[
13.37009287492902, 52.44814983972436],
[
13.37118561001558, 52.44874834445871],
[
13.37174232868328, 52.44906374784002],
[
13.37271005284888, 52.44959483241811],
[
13.37359695959115, 52.45006965427803],
[
13.3747034292659, 52.45070158902308],
[
13.37508425015925, 52.4508731616153],
[
13.37530674431366, 52.45096018400088],
[
13.37558158785187, 52.45107958213099],
[
13.37605685990185, 52.4512841563029],
[
13.37642441062161, 52.45142280228237],
[
13.37742474351654, 52.45176275338758],
[
13.3780278035004, 52.45194269348149],
[
13.37815827238338, 52.4519778390405],
[
13.37808118254825, 52.45202962466031],
[
13.37829451775066, 52.4520861546161],
[
13.38252066677197, 52.45311134572705],
[
13.38285549119088, 52.45256892340927],
[
13.38391488993445, 52.45274959334866],
[
13.3842102910778, 52.45279918089491],
[
13.38464161479168, 52.45282010621742],
[
13.38480059192241, 52.45283517082542],
[
13.38596147992653, 52.45294071487208],
[
13.38781469035528, 52.45313194990463],
[
13.38901369522894, 52.45330422795352],
[
13.38944490197815, 52.45328046779188],
[
13.39016409765448, 52.45326483164939],
[
13.39070367112175, 52.45325970781494],
[
13.39104265779963, 52.45328321167853],
[
13.39132828705205, 52.45332449349526],
[
13.39165138004353, 52.45339371020985],
[
13.39194880763059, 52.45329265245722],
[
13.39201334002096, 52.45313540989832],
[
13.3924687397163, 52.45312471853099],
[
13.392998845719, 52.45309700693492],
[
13.39369786617938, 52.45308715130651],
[
13.39488367535485, 52.45307294373654],
[
13.39636153766748, 52.45307843653396],
[
13.39680129444841, 52.45306581066024],
[
13.39915812544599, 52.45298660363829],
[
13.39923773016992, 52.45298388071891],
[
13.39981198378546, 52.45288710982356],
[
13.40082107458279, 52.45286064024374],
[
13.40244718287711, 52.45284396113451],
[
13.40520099543332, 52.45280852532169],
[
13.4061662790861, 52.45278264711366],
[
13.40784202352047, 52.45273767581656],
[
13.40789031772862, 52.45273641702095],
[
13.40818323649219, 52.45272904940671],
[
13.40861407342462, 52.45334234020018],
[
13.40877219026829, 52.45331243365732],
[
13.40937140049057, 52.45319508102951],
[
13.41104431456623, 52.45303645757752],
[
13.41156786935784, 52.45300595457548],
[
13.41262845761225, 52.4529171048614],
[
13.41301210188326, 52.45284014666421],
[
13.41486341329156, 52.45251417501284],
[
13.41516503684616, 52.45246195823384],
[
13.41613613872793, 52.45233247344455],
[
13.41683662992296, 52.45223907998716],
[
13.41768244494836, 52.45220130199412],
[
13.41828204545029, 52.45297042857202],
[
13.41836187097091, 52.45307500350609],
[
13.41878190344992, 52.45361714724765],
[
13.41885272386138, 52.45370211334047],
[
13.41931912044089, 52.45424343779865],
[
13.41957382712243, 52.45457273522796],
[
13.41965776824794, 52.45468064182042],
[
13.41987372405781, 52.45499486169975],
[
13.42073119325961, 52.4562418398178],
[
13.42076373381932, 52.45628908062363],
[
13.42084956100989, 52.45638413754948],
[
13.42088022867405, 52.4564167255041],
[
13.42108498663963, 52.45663781350883],
[
13.42119645074374, 52.45675178838859],
[
13.42139235661144, 52.45671123553725],
[
13.42211477787807, 52.45666350518784],
[
13.42282637567759, 52.45664702813575],
[
13.42352931485109, 52.45661354563743],
[
13.42426174654159, 52.45660464518702],
[
13.42494648504002, 52.45659736650598],
[
13.42565824556079, 52.45662464161836],
[
13.42656951276154, 52.45669943421337],
[
13.42487453297701, 52.45776588297385],
[
13.42461547586202, 52.45789755643874],
[
13.42437136763208, 52.4579971696759],
[
13.42287709140118, 52.45854140197822],
[
13.42060765202209, 52.45936773212815],
[
13.42075834651942, 52.45960535319415],
[
13.42142499393213, 52.4606550778602],
[
13.4232325416442, 52.46040367512531],
[
13.4230090501123, 52.46131812342918],
[
13.42197192479232, 52.46151603475239],
[
13.42203072158217, 52.46160717935336],
[
13.42204885535064, 52.46185778086707],
[
13.4220842875964, 52.46212027571652],
[
13.42213343789605, 52.46246035595769],
[
13.42214024075305, 52.46251123668752],
[
13.42209703517446, 52.46272164807267],
[
13.42189988806021, 52.46286726320982],
[
13.4217095959838, 52.46349668428688],
[
13.42168563631286, 52.4639524861699],
[
13.42164821279683, 52.46466809178595],
[
13.42162370796594, 52.46513647504727],
[
13.42162039867456, 52.46530031045844],
[
13.42155296175436, 52.46576205840785],
[
13.42154204930853, 52.46583825302641],
[
13.42150747631561, 52.46583495760058],
[
13.42126606980845, 52.46581242963256],
[
13.41899981500223, 52.46559178622153],
[
13.41732599879988, 52.46543694859233],
[
13.41687946171508, 52.46539607363945],
[
13.41686015334105, 52.46547521880621],
[
13.41676751155387, 52.46589279099061],
[
13.41670525866401, 52.4661722799699],
[
13.41656059608417, 52.46683493711026],
[
13.41603920643839, 52.46915133233842],
[
13.41578024876252, 52.47030998123304],
[
13.41559580390645, 52.47098613686782],
[
13.41501711053023, 52.47310667746041],
[
13.4150079693134, 52.47313982474452],
[
13.41467201760674, 52.47437113092327],
[
13.4141248706241, 52.47637551504133],
[
13.41369816293037, 52.47793900986195],
[
13.41368679471323, 52.47798042144383],
[
13.4135879283361, 52.47834288616025],
[
13.4135407215446, 52.47851544962237],
[
13.4135407215446, 52.47851544962237],
[
13.4135407215446, 52.47851544962237],
[
13.41348819666088, 52.47870822519066],
[
13.41093853129592, 52.47790228512731],
[
13.41088477756966, 52.47772342715481],
[
13.40744129399503, 52.47811209487944],
[
13.40688996600736, 52.47817443350024],
[
13.40681549652214, 52.478185169946],
[
13.40670612562434, 52.47820806437306],
[
13.40667184285161, 52.47821788680966],
[
13.40662284388516, 52.47823316420167],
[
13.40665684627857, 52.47835267035642],
[
13.40680204947603, 52.47886198818409],
[
13.40623957721861, 52.48015719827663],
[
13.40606316718484, 52.48098568987653],
[
13.40615240055668, 52.48122842679019],
[
13.40625087932883, 52.48197816140741],
[
13.40627699144013, 52.48197623281144],
[
13.40634953389733, 52.48247445086773],
[
13.40639516370642, 52.48277031187833],
[
13.40641972080311, 52.48293410841325],
[
13.40669867201589, 52.48479502326938],
[
13.40671618211555, 52.4849115327635],
[
13.40676529936286, 52.48521512916732],
[
13.40682342399393, 52.48539246905003],
[
13.406864632947, 52.48548017292546],
[
13.40692048144199, 52.48557832937616],
[
13.40697809801354, 52.48566282820674],
[
13.40704264938984, 52.4857445537796],
[
13.4071138914232, 52.485823775253],
[
13.40719146256978, 52.4858999526993],
[
13.40745867882762, 52.48614921970405],
[
13.4070200853521, 52.48598456580928],
[
13.40629694054865, 52.48571305956234],
[
13.40439186815571, 52.48499724354436],
[
13.40154721197379, 52.48500103311337],
[
13.400490866753, 52.48384656185452],
[
13.40046032024145, 52.48381325000568],
[
13.40038582635067, 52.48373186128715],
[
13.40021825950321, 52.48373549519835],
[
13.3981107983286, 52.483781593188],
[
13.39602384836042, 52.48382823286296],
[
13.39423816273044, 52.48386626069553],
[
13.39424196666912, 52.48434278127043],
[
13.39425338408981, 52.48577135415827],
[
13.39258929042122, 52.48578425138487],
[
13.38629089550947, 52.48582635791649],
[
13.3862754675146, 52.48515910044031],
[
13.38626845720565, 52.48486348989768],
[
13.38576116624062, 52.48486704178183],
[
13.38459882222975, 52.48487410645989],
[
13.38447946871148, 52.4848745812301],
[
13.38384590534117, 52.48487822588601],
[
13.38345736544655, 52.4848803937823],
[
13.38240466368921, 52.48488649384117],
[
13.38199948898726, 52.48488880235797],
[
13.37704013385852, 52.48491673042595],
[
13.37635022159842, 52.48492228315842],
[
13.37430952940687, 52.48493412595306],
[
13.37403706469655, 52.48493570153753],
[
13.37279262996442, 52.48494445215773],
[
13.37238296865419, 52.48494554974713],
[
13.37193480931513, 52.48494827065755],
[
13.37156897311252, 52.4849503585077],
[
13.37152793834273, 52.48488672894467],
[
13.37146904652826, 52.48488768043798],
[
13.37148905760041, 52.48487055761348],
[
13.37115335727289, 52.48430218742362],
[
13.36898719476238, 52.48064616738733],
[
13.36638406775622, 52.47628012567252],
[
13.36625065134183, 52.47605496638253],
[
13.36619055353266, 52.47576849428223],
[
13.36637498391075, 52.47512360198886],
[
13.36649116769241, 52.47477083086919],
[
13.366584757146, 52.47448236003043],
[
13.36663178658546, 52.47441155249017],
[
13.3670497224344, 52.47383304993236],
[
13.36726627326258, 52.47360569324897],
[
13.36730510730515, 52.47356587414046],
[
13.36738767743795, 52.47347824780334],
[
13.36778170583528, 52.47314414864533],
[
13.36805232294741, 52.47294827497106],
[
13.3682455201424, 52.47285199222014],
[
13.36892515179231, 52.47249613396567],
[
13.36946204592638, 52.47230416218307],
[
13.37002253039306, 52.47216670304725],
[
13.37091843207313, 52.47204183020219],
[
13.3710841029947, 52.47204398569269],
[
13.37099675929778, 52.4711549386893],
[
13.37095864179135, 52.47071563983563],
[
13.37094600528199, 52.47061315563668],
[
13.37093693468671, 52.47054465168981],
[
13.37075876346042, 52.47029189893816],
[
13.37074275309119, 52.47026903619155],
[
13.37061977695624, 52.46901708825335],
[
13.37055478544121, 52.46835735867656],
[
13.37044498428724, 52.46722110716513],
[
13.37042951892709, 52.46704177400936],
[
13.37036689675871, 52.46624660831957],
[
13.37035129467914, 52.46604912017148],
[
13.37013353937377, 52.4633170009828],
[
13.37011778953584, 52.46310351470876],
[
13.36993057758425, 52.46071657852496],
[
13.36991529217071, 52.46052789853091],
[
13.37023079919203, 52.46042307006436],
[
13.37046772553241, 52.46032984417717],
[
13.3705794953321, 52.46026555620327],
[
13.37067675019047, 52.4601931479993],
[
13.37075790690655, 52.46011360479682],
[
13.37081941580464, 52.46003222155458],
[
13.37086408093233, 52.4599467575008],
[
13.37091009919589, 52.45981617929172],
[
13.3709395028986, 52.45968385752975],
[
13.37095045251229, 52.45959508506465],
[
13.37095365246549, 52.45946153827917],
[
13.37094732960208, 52.45937991844467],
[
13.37094089450909, 52.45933865207712],
[
13.37093199966634, 52.45928210170354],
[
13.37091304158663, 52.45920315078873],
[
13.37087416183749, 52.45908596007444],
[
13.37082228825129, 52.45897053873665],
[
13.37078086294098, 52.45889486456589],
[
13.37068813928261, 52.45877216482571],
[
13.37060581757598, 52.45869721096226],
[
13.37050889557411, 52.45862905589949],
[
13.3704018478075, 52.45857031565954],
[
13.37022606669875, 52.45849992239019],
[
13.36974796942599, 52.45839687730064],
[
13.36973795143427, 52.45824164201895],
[
13.36960951282541, 52.45664599780535],
[
13.36960110341983, 52.4565272550808],
[
13.3696531452719, 52.45644585182526],
[
13.37004363507295, 52.45581443116478],
[
13.37016856575521, 52.45561311318493],
[
13.36769661325177, 52.45567540307543],
[
13.36732927722118, 52.45568484405001],
[
13.36664994857396, 52.45570114799609],
[
13.3665492940934, 52.45462036312074],
[
13.36641531685411, 52.45464550298395],
[
13.36501698271726, 52.45476545679682],
[
13.36388319946182, 52.45489685690514],
[
13.36395978524058, 52.45577015980091],
[
13.36191935582848, 52.45594176525245],
[
13.35955230923014, 52.45494341829814],
[
13.35950353664142, 52.45492281671917],
[
13.35930759905555, 52.45484013866199],
[
13.35922441782175, 52.45495166491219],
[
13.35916409384045, 52.45505542369203],
[
13.35911334281681, 52.45516118133572],
[
13.35905884266282, 52.45530494748021],
[
13.35902228631522, 52.45545091118965],
[
13.359004310012, 52.45559422068547],
[
13.35900255742299, 52.45574331886731],
[
13.35901832317048, 52.45588481733293],
[
13.35905342301386, 52.45603948124063],
[
13.35922554897859, 52.4566289991799],
[
13.35923341844497, 52.45667197707603],
[
13.35921752835638, 52.45671121639391],
[
13.35918355207238, 52.45675158318613],
[
13.35912859434023, 52.45679028477367],
[
13.35907728645144, 52.45680733479032],
[
13.35882297547907, 52.45684513574673],
[
13.35846966457232, 52.45690086643463],
[
13.35748930741197, 52.45705097732488],
[
13.3568527714633, 52.45714919822645],
[
13.35656298160038, 52.45719419324722],
[
13.35598522677637, 52.45728310683862],
[
13.35589571500936, 52.45729692243719],
[
13.35581929100512, 52.45729369174265],
[
13.35572870671126, 52.45724495197227],
[
13.35570245286249, 52.4571730819574],
[
13.3557349915941, 52.45703133421446],
[
13.3557879268701, 52.45670952426566],
[
13.35580650856853, 52.45646924185491],
[
13.3557956988671, 52.45631265536331],
[
13.35591112297794, 52.45577268271095],
[
13.35597623728278, 52.45562121308141],
[
13.35611910795432, 52.4556114739575],
[
13.35624893987041, 52.45527384187367],
[
13.35637217488255, 52.45502256416952],
[
13.35645860461336, 52.4548572123778],
[
13.35668826888968, 52.45444323449854],
[
13.35690710336685, 52.45409331214185],
[
13.3569026293615, 52.45403119849329],
[
13.35729310637599, 52.45344817211533],
[
13.35725805298013, 52.45332703099776],
[
13.35744517747608, 52.45302242211595],
[
13.35791109193916, 52.45228165531923],
[
13.35792984030406, 52.45229104488985],
[
13.35821721797099, 52.45181877638782],
[
13.35843909535447, 52.45142311170808],
[
13.35847791000185, 52.4513246070844],
[
13.3584975058175, 52.45125427955867],
[
13.35855371595999, 52.451148085112],
[
13.35862893820784, 52.45100769142675],
[
13.35876109267845, 52.45088189648804],
[
13.35896116432144, 52.45061955557431],
[
13.35900238652768, 52.45054388441226],
[
13.3594649391018, 52.44968833350252],
[
13.35970803933736, 52.44941080975486],
[
13.35985619935644, 52.4491645275688],
[
13.36019473593672, 52.44855063684744],
[
13.3606118358332, 52.44774162383587],
[
13.36086210084563, 52.4473186962738],
[
13.36094947071862, 52.44711271969948],
[
13.36101233534376, 52.4470883250726],
[
13.36105171704127, 52.44701498576944],
[
13.36106987446061, 52.44698114372697],
[
13.36120435365231, 52.44684888022089],
[
13.36111453620222, 52.44681641354305],
[
13.3613237580697, 52.44645918118508],
[
13.36148837534925, 52.44623675060106],
[
13.36202459863296, 52.44527826781215],
[
13.36235625779353, 52.44462786596749],
[
13.36238376121532, 52.44457247462558],
[
13.36242559067923, 52.44459620517185],
[
13.3624913020406, 52.44446010164193],
[
13.36264418917045, 52.44414812780615],
[
13.36275045324316, 52.44420867100099],
[
13.36274542459601, 52.44421791689327],
[
13.36286111351936, 52.44428468238355],
[
13.3629505916295, 52.44431238362714],
[
13.36308423724073, 52.44439896140452],
[
13.36312572472506, 52.4443376693087],
[
13.36336158883434, 52.44445152681598],
[
13.36422815974076, 52.44488485207579],
[
13.36424120041571, 52.44491543846355],
[
13.36460361581629, 52.44506624312456],
[
13.36521021230331, 52.44532139212947],
[
13.36559500361156, 52.44548446617436],
[
13.36562686841168, 52.44547051602395],
[
13.36577348546919, 52.44555999535853],
[
13.36583561943895, 52.44561747254509],
[
13.3658862548401, 52.44569119169591],
[
13.3660358445109, 52.4459145009039],
[
13.36617949899573, 52.44599246921813]
]
]
},
"properties": {
"name": "Tempelhof"
}
}
]
}
Currently by percent only
I am trying to process a 1.2GB USA Census Block Group file. When trying to do the basic operation:
mapshaper -p 0.1 usa_census_block_groups.shp -f shapefile -o test.shp
I get the following error:
buffer.js:194
this.parent = new SlowBuffer(this.length);
^
RangeError: length > kMaxLength
at new Buffer (buffer.js:194:21)
at Object.fs.readFileSync (fs.js:302:14)
at Object.Node.readFile (/usr/local/lib/node_modules/mapshaper/mapshaper.js:1299:20)
at Object.MapShaper.readGeometryFile (/usr/local/lib/node_modules/mapshaper/mapshaper.js:9946:20)
at Object.MapShaper.importFromFile (/usr/local/lib/node_modules/mapshaper/mapshaper.js:9934:27)
at /usr/local/lib/node_modules/mapshaper/bin/mapshaper:43:28
at Object.Utils.mapFilter (/usr/local/lib/node_modules/mapshaper/mapshaper.js:92:19)
at Object.Utils.forEach (/usr/local/lib/node_modules/mapshaper/mapshaper.js:861:9)
at procFiles (/usr/local/lib/node_modules/mapshaper/bin/mapshaper:37:11)
at Object.<anonymous> (/usr/local/lib/node_modules/mapshaper/bin/mapshaper:19:3)
v0.1.12 includes some new options:
--filter
takes a boolean JS expression and applies it to every record in a dataset. Whenever an expression evaluates to false, the corresponding record is removed. You could do mapshaper --filter "POPULATION < 10" census_tracts.shp
to remove tracts with fewer than 10 residents (assuming there is a field named POPULATION).
--split
takes a field name and splits a layer into multiple layers based on the values in the field. For example, mapshaper --split STATE counties.shp
would likely generate 50 52 or more state-level shapefiles (50 states, D.C., Puerto Rico, ...) with names like counties-OR.shp
, counties-WA.shp
etc.
--subdivide
recursively splits a layer based on the result of a boolean expression. mapshaper --subdivide "sum('POPULATION') >= 50000" counties.shp
generates multiple shapefiles, each with a group of counties with a combined population of less than 50000. (sum() takes a record-level expression as an argument). I expect this option won't be used much, but I needed it for a project ;-)
--merge-layers
merges split-apart layers back together. It's useful if you need to split a layer, process each partial layer separately and then merge the layers back together into one output file.
To use these and other commands in combination, you need to know the order in which they are performed. This is the current order:
I'd appreciate suggestions for other useful slicing and dicing operations
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.