Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I have two shapefiles of the state of NSW, Australia. The first one has some regions that are useful for economic reasons, while the second has information about the koala population, in much smaller polygons.
Here I show both maps that I get when I plot these shapefiles:
Areas of NSW
Probability of finding a Koala
What I'm attempting to do is to add the region name of the first picture to each of the quadrants of the second file.
Is this possible? Which would be a method to match the polygons of both files? Thanks
You are likely looking for sf::st_join().
What it does is it transfers the non-spatial information from one {sf} object to another based on spatial relation. For the function to work both spatial objects need to have the same CRS (so consider sf::st_transform() if they do not).
Note that the order matters: you either add koala info to administrative areas, or area info to koala regions.
Also note that some koala regions are likely to straddle the border of two regions; these will be split. So expect slightly more rows coming out that what went in.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to create a pie chart superimposing multiple variables using r-plotly.
For instance, I have values for the global population of a country, it's economically active population, and the economically active male/female.
I want to get all those data inside a single pie chart, with the full cercle as the golbal population, a part of this cercle representing the active population, which is divided itslef in 2 parts, male/female.
I unfortunnatly have no idea how to archieve it and I don't even know is it's possible.
I didn't manage to do it using the function :
plot_ly(...)
Thank you for your help and happy new year !
I think a "sunburst" plot could be what you are looking for.
Here is an example on a fake dataset:
library(sunburstR)
dat <- data.frame(G = c("male-active", "male-inactive", "female-active", "female-inactive"),
N = c(100, 100, 100, 100))
sunburst(dat)
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I plot two hexbin graphs with R (with package 'hexbin') from data file with two columns gr and ug.
The first plot : gr as a function of ug
The second plot : ug as a fonction of gr
Why aren't they perfectly symmetrical?
Thanks in advance
Notice that in both cases the hexagons are oriented to have 2 sides vertical and no sides horizontal. To be perfectly symmetric one of the plots would need to have the rotated hexagons (2 sides horizontal).
So the binning is slightly different between the 2 graphs and points that are near the boundary in the 1st plot may fall into a different cell (symmetrically) in the 2nd plot. So while the 2 plots are similar overall you will see some minor differences due to how the data is binned.
This is true in general for plots/techniques that depend on binning continuous data, a slight change to how the binning is done will results in usually minor changes in the results. It is good to do multiple plots with small changes to the options that determine the binning to see how much things change.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Well I have a network dataset in NodeXL and I am trying to visualize it on a world map. My dataset has
Nodes with an attribute of a country
Links. Unweighted connections between the nodes
I tried to do it with NodeXL and exporting the file and importing to Gephi. But, I cannot find a way to visualize it on a world map in base of the attribute of nodes.
Also, I know about D3.js but I cannot find any example or tutorial with networks on maps.
Can you please provide me with examples in NodeXL, Gephi, D3.js or any other library to do this.
Imagine the result something like this:
In Gephi, you can use a map-based layout to visualize your network based on node location. You need to have two attributes containing the geocoded coordinates of your nodes: latitude and longitude. There are two plugins you can use for the visualization (neither comes with Gephi by default, you have to install them from Tools -> Plugins):
GeoLayout - when you apply that one, you have to specify the names of the attributes where longitude and latitude are recorded and select a projection (e.g. Mercator). Your nodes will be laid out accordingly.
Map of countries - that's a plugin that displays a (fairly crude - not too detailed) outline map as a background to your network.
You can use both in sequence - though frankly I've had more success using GeoLayout, exporting the result to a vector graphic, an overlaying it on top of a map image. If your network is large and nicely spread across the geographic area, you won't even need to overlay it on a map - it will already look like one. In the Facebook visualization you've posted above for example, the outlines of continents emerge just based on where nodes/users are concentrated.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
This is a question both about best practices for visual representation of data and about how to draw plots in R/ggplot2.
I am trying to find a way to graphically represent the story told here:
"We had 2000 test cases, of which 500 had errors. After investigation, we found that 400 of the tests were Big and 1600 were Small; only 25 of the Big tests had errors, so we set them aside, leaving 1600 Small tests, of which 475 had errors. We then found that 400 of the Small tests were Clockwise and 1200 were Counter-Clockwise; only 20 of the Small Clockwise tests had errors, so we set them aside, leaving 1200 Small Counter-Clockwise tests, of which 455 had errors."
In other words, I am using categories to separate my test cases, and I want to represent how the fraction of errors in each category changes with my progress.
Here's some R with the data:
tests <- data.frame(n.all=c(2000,400,1600,400,1200),n.err=c(500,25,475,20,455),sep.1=as.factor(c("all","Big","Small","Small","Small")),sep.2=as.factor(c("all","all","all","Clockwise","Counter-Clockwise")))
With this small amount of data, a simple numeric table might be the best choice; let's assume that the story continues, with more and more separating categories being used, so that simply listing the numbers isn't the best choice.
What would be a good way to represent this data? I can think of a few possibilities:
Pie charts, showing slices of the pie being taken away, and the breakdown of errors/no errors in what remains
Bar charts, similar
Bar charts with ribbons showing the "flow" of separating away categories, like Minard's chart of Napoleon's march
Similar, but with the bar charts showing the fractions horizontally rather than vertically
All four methods show the absolute amount of test cases decreasing, and the fraction of errors in the separated category as well as what remains. I think I like #4 best, but I've got an open mind.
How should this kind of data be represented, and can R/ggplot2 be used to do so?
Remember the 3 things that should be in line when drawing graphs; the message you are telling, the message the data is telling you and the message the graph is telling you.
In my opinion your option 4 is the best one to get the message across consistently.
I also arrive at number 4 by sheer elimination: ;)
Columns are not suitable since you are combining vertical representation with a horizontal flow, comparing pie charts are also not easy to do (even within a pie chart it is already difficult to compare the different parts) so they are not an option either. Leaving you with option 4 indeed :)
You can also try a Sankey Diagram. Sankey Diagrams in R? might be helpful
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am trying to convert the SVG File to SHP (Shape File format) and then get it imported into GeoServer.
Is there any convertor available OR is there any mediating format in which I can get it converted and finally get it in SHP format?
I already have shape file of Map of India. Now, there are some odd 60 districts got added in recent years. New districts are separate from the old ones. So, the total area of the country has not changed, but got divided.
What I am thinking is, if I can merge the new layer which I have of new districts in SVG format to the original SHP file data and get the final coordinates mapped according to the SHP file, then the problem can be sorted.
If anyone has done it and can help, will be great!! Thanks!!
Highly unlikely. SVG is a 'drawing' format, and so there's no guarantee that the lines have coordinates that are anything in the real world - they might be in centimetres based on a piece of A4-size paper.
So you would have to at least work out the transformation from those coordinates to lat-long, or some other coordinate system. This may be non-linear...
However SVG is an XML-based file, so you can open it in a text editor and get a look at it. If you can figure out what elements hold the coordinates you need, then you can write a script (I'd do it in Python, but whatever language you can program in that has XML support will do) to strip out the coordinates. Then it might be possible to think about converting them to a shapefile - or maybe GML - an XML-based standard format for geographical data.
But to be honest, it might be much easier to source a shapefile with the boundaries you want in it.