Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement more mapshaper commands #12

Open
10 of 29 tasks
ateucher opened this issue Nov 21, 2015 · 9 comments
Open
10 of 29 tasks

Implement more mapshaper commands #12

ateucher opened this issue Nov 21, 2015 · 9 comments

Comments

@ateucher
Copy link
Owner

ateucher commented Nov 21, 2015

https://github.com/mbloch/mapshaper/wiki/Command-Reference

@timelyportfolio
Copy link
Contributor

@ateucher, you're doing very fine work. Unfortunately, my domain ignorance is preventing me from helping much, but I am following along. Let me know if I can do anything.

@ateucher
Copy link
Owner Author

Thanks @timelyportfolio! I'm really close to having something that people can kick the tires of. I'm trying to get all the methods implemented and tested for the five core functions checked above (simplify, erase, clip, dissolve, explode) before I put a note on Twitter asking people to try it out and provide feedback.

Any time you want to try to incorporate your widget is fine by me - but no rush :)

@ateucher ateucher mentioned this issue Nov 25, 2015
@ateucher ateucher added this to the v0.1 milestone Jan 20, 2016
@ateucher ateucher removed this from the v0.1 milestone May 17, 2016
@bhaskarvk
Copy link

Could you also add the convert feature. It might come in handy for converting to/from various formats w/o needing rgdal.
Also I found that reading topojsons exported from https://pitchinteractiveinc.github.io/tilegrams/, using either rgdal or geojsonio doesn't quite work, but if I export that topojson to a shapefile using mapshaper then the resulting shapefile works well.
So there's a use case for supporting convert function.

@ateucher
Copy link
Owner Author

ateucher commented Oct 9, 2016

Hi @bhaskarvk, thanks for the note.

By convert, do mean the format output option listed here? Unfortunately the -o options aren't currently exposed in the mapshaper command line API, so that's not currently possible. I will think on it a bit more though

As for the topojson read issue, could you open up an issue in https:/github.com/ropensci/geojsonio?

@ifoxfoot
Copy link

Hello,
Thanks for making this package! Any plans to add a mosaic function? It would be super useful for analyzing polygons that change through time.

@ateucher
Copy link
Owner Author

ateucher commented Oct 27, 2022

Hi @ifoxfoot - just to be clear, are you referring to implementing the mosaic command available in the mapshaper javascript library? Or a mosaic in the ArcGIS sense? If the former, then happy to add it to the roadmap, but if the latter it would be out of scope as mapshaper (and hence rmapshaper) doesn't deal with raster data.

@ifoxfoot
Copy link

@ateucher the one in the mapshaper library. I want to flatten some polygons together. Thanks for responding!

@ateucher
Copy link
Owner Author

You should be able to achieve what you're after with sf::st_intersection() - when given a single layer it intersects with itself. You can also try with rmapshaper::apply_mapshaper_commands() - it's not well documented and only works with geojson objects, but can apply any of the mapshaper commands, even if they're not implemented with their own function in rmapshaper:

library(rmapshaper)
library(sf)
#> Linking to GEOS 3.10.2, GDAL 3.4.2, PROJ 8.2.1; sf_use_s2() is TRUE

m = rbind(c(0,0), c(1,0), c(1,1), c(0,1), c(0,0))
p = st_polygon(list(m))
n = 10
l = vector("list", n)
for (i in 1:n)
  l[[i]] = p + 3 * runif(2)
s = st_sfc(l)
plot(s, col = sf.colors(categorical = TRUE, alpha = .5))

i = st_intersection(s)
plot(i, col = sf.colors(categorical = TRUE))
title("non-overlapping intersections")

s_geojson <- rmapshaper:::sf_to_GeoJSON(s)

j <- apply_mapshaper_commands(s_geojson, "-mosaic") |>
  rmapshaper:::GeoJSON_to_sf()

plot(st_as_sfc(j), col = sf.colors(categorical = TRUE))

Created on 2022-10-27 with reprex v2.0.2

@ifoxfoot
Copy link

@ateucher I keep running into this bug with very large/messy datasets when I use st_intersection (although maybe it's fixed now with GEOS 3.10, I haven't tried in awhile). I will try apply_mapshaper_commands() though! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants