chrisbrunsdon / getcartr Goto Github PK
View Code? Open in Web Editor NEWFront end for rcartogram
Front end for rcartogram
Dear Chris,
I'am new to geocomputation with R, and I do not know how to use the function/methods belonging to the objects created/worked on by package sp. As I get a log of warning and error messages because of the changes in the PROJxxx libraries, I would like to use sf functions.
Is there a description of waht are the functions in your package - espacially the not exported dotted ones - are doing?
Or should I read the documentation of Rcartogram resp. the Newman/Gastner documention of the C-routine and redo the frontend on my own?
Best Wishes
Rolf
P.S.: I wonder if this question deserves the heading "Issues". If not please let me know where to put it instead.
Hi there
First --- thanks for a really neat package.
I encountered a problem while running a variant of an example from http://vietletruc.com/tag/cartogram/. (on a Windows machine)
quick.carto
fails with the following message.
d> world.carto <- quick.carto(world, world@data$Population, blur = 0)
Error in `proj4string<-`(`*tmp*`, value = <S4 object of class "CRS">) :
Geographical CRS given to non-conformant data: -189.000000 -192.188202 185.811798
Called from: stop(mess)
If I look at the world
object which is a SpatialPolygonsDataFrame I find that it uses (as I expected) a longlat projection. And both the latitude and longitude values are all "legal".
d> world@proj4string
CRS arguments:
+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
d> range(coordinates(world)[, 1])
[1] -178.1269 179.2159
d> range(coordinates(world)[, 2])
[1] -80.50275 78.60600
d>
However if I overwrite the proj4string, and then try quick.carto
again, everything is fine.
d> world@proj4string <- CRS(as.character(NA))
d> world.carto <- quick.carto(world, world@data$Population, blur = 0)
d>
I suspect (but have no evidence) that somewhere in the internals of quick.carto
a new expanded copy of the SpatialPolygonsDataFrame is made including the surrounding "sea" as described in the Gastner Newman paper. And that the copy simply uses the same proj4string / CRS as the map being morphed. And that when the longlat values are expanded, they exceed the legal values for longitudes and latitudes. Or perhaps simply that at some stage during the morphing process the (warped) long lat values for the cartogram exceed the legal values for longitude and latitude. Hence this error message, which I think comes from a validity check during the creation of a (copy of) SpatialPolygonsDataFrame, when the CRS is longlat .
If I am correct, wiping out the proj4string / CRS in the way I have above is actually the correct thing to do I think --- since after morphing it would be fair to say that the coordinate reference system of the warped map is no longer any type of longitude latitude projection (nor indeed any other projection likely to be known to standard geography and supported in the CRS / proj4 universe).
Not sure what to do, but maybe this issue will help others who may experience a similar problem.
Once again, really like the package, thanks.
Geoff
I am rather new in the field of making map. I am not therefore completely sure that my question concerns only the getcartr package.
I am trying to map Swiss states according to the elections résultat, and I have to deal in this sort of exercices with à states containing polygons with the same number in the key column i need to merge th sp objet with my data. Those duplicated polygons are differentiated with another columns, the usual plot don't make any issue.
But I failed to use the quick.carto function, with the error "invalid class "spatialpolygjns" object ; non-unique polygons ID slot value"
Is there any way to solve this error in the quick carto function ?
Thanks in advance for the help
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.