Questions tagged [ggplot2]

Use this tag when referring to the R package for high level data visualization and mapping.

Filter by
Sorted by
Tagged with
2
votes
0answers
37 views

Union anti-meridian “multipolygons” after re-centering world map

My goal is to create a world map (using ggplot2) with a Pacific perspective. I have managed to re-center the map, by following this solution. Code below: # world country layer sppolys <-...
0
votes
1answer
46 views

Plotting Geographical Grid from Long/Lat Coordinates in R

I have a file of coordinates (Long/Lat) that should enable me to plot a series of 10km grid squares covering the UK. However, for each grid square I have five sets of coordinates by way of plotting ...
1
vote
0answers
52 views

ggplot with island (“Alaska problem”)

The data for this example can be found here: https://github.com/davidbaniadam/maps The problem is essentially the same with Alaska and mainland USA, i.e. I want the size of Alaska to be correct in ...
-1
votes
1answer
57 views

Reorder legend in ggplot object [closed]

I met some trouble when dealing with the order of ggplot legend. I plotted three lines in one graph, and I tried to use 'scale_colour_mannual' to change the order as the line from top to bottom, but ...
0
votes
0answers
19 views

Polygon boundary is not properly connected in R

I have two points sets, when plotted using geom_point, they look like: What I want to do is draw a polygon using these two datasets, and I expect to get a ring-shape polygon. However, when I use ...
2
votes
0answers
48 views

Assign different colours to intersection between two polygons and difference area

I am quite new to GIS using R. I have two sets of data, upon which I could create two polygons like this: What I want to do is colour the common area (inner 'circle') and the space between borders. ...
0
votes
1answer
31 views

Order features in a spatialpolygonsdataframe in ggplot2

I have a spatialpolygonsdataframe with many overlapping features. I want to create a map in which the smaller features are displayed on top of the larger ones so that the small ones aren't fully ...
1
vote
1answer
42 views

Splitting an administrative region into given number of parts

I have the following plot. I want to divide the administrative region into given number (say 20) equal parts. library(maps) data(world.cities) Pakistan <- data.frame(map("world", "Pakistan", ...
0
votes
1answer
184 views

Simplifying a SpatialPointsDataFrame in ggplot world

I've been working on a map showing lines running across Europe. Each line is coming from a GPX file, parsed in like so: spdf <- readOGR("data/file.gpx", layer = "track_points") Now, if I plot the ...
2
votes
1answer
411 views

Overlay shapefile on multiband raster using ggRGB and ggplot2 in R

I am trying to use ggplot2 to map a polygon feature class over a raster brick (created from multiple Landsat band images). I'm able to map the polygons and the raster separately, but when I try to ...
1
vote
1answer
33 views

Error in mapping connections with great circles [closed]

I am fairly new to R and to map plotting. I am trying to overlay some network information on a world map. I loaded a shapefile from Natural Earth as a large SpatialPolygonsDataFrame via readOGR. I ...
-1
votes
1answer
66 views

Dealing with Islands with sf objects and the tmap package [closed]

I have the bounderies for the municipalities in the "capital region" of Denmark. The acctual map looks like this: The yellow island is the fourth row in my sf object. I am trying to folllow the ...
13
votes
2answers
401 views

How to create a map of Denmark with ggmap

I have installed the following two packages: library(ggmap) library(maps) I have found code online to create a world map (see below). How do I zoom the plot on a country level? For example, Denmark. ...
1
vote
0answers
136 views

could not find function “merge_eurostat_geodata”

Just a couple of codes with the same error at the time of merge data: FIRST CODE: library(eurostat) library(dplyr) library(ggplot2) library(stringr) fer <- search_eurostat("fertility") ...
2
votes
1answer
123 views

Binding multiple polygons in R

I have a directory that contains around 700 .shp files. I want to create a map in R that displays all of them. The easiest way i could think to do this was to bind them all together and then use ...
5
votes
1answer
991 views

Creating an sf object from the maps package

I am trying to use data from the maps package in an sf workflow. I'm not sure if I have the operation correct (see below). It seems to work until state 20 (massachusetts). What am I doing wrong? Maybe ...
2
votes
3answers
1k views

Adding a legend to points in the tmap package

I am trying to create a map with several points (about 20), where each point will be represented by a number, and where a legend will have these numbers and names of my points. Is it possible to do ...
1
vote
1answer
455 views

Setting fill to a variable based on data within SpatialPolygonsDataFrame?

I'm currently on the cusp of getting done what I want to get done - but having a slight problem with referring to my data from within R's sp SpatialPolygonDataFrame object. The issue is how ggplot2 ...
1
vote
1answer
65 views

Using R to create a choropleth generated from lat/lon lists - with data generated internally

a friend referred me here as opposed to the regular Stack Overflow site, as this community maybe better able to help! My issue is largely with the syntax and framework of ggmap,ggplot, and the sp ...
0
votes
1answer
83 views

Combining postal codes into sales territories by value using R and ggplot2?

I have the shapefile for Canadian census subdivisions. For each subdivision I calculated some value (someValue). I want to combine census subdivisions into territories in such a way that territories ...
0
votes
1answer
102 views

Stacked area graph in ggplot2 is empty [closed]

I am trying to make a stacked area graph in ggplot2: Zooplankton<-read.table("clipboard".header=TRUE) TransZoop Zoop DensZoop 0 Copepoda 0.066 0 Nauplii 0.425 0 Cladocera 0.199 0 ...
1
vote
0answers
108 views

R colored raster from QGIS to ggplot or tmap

I am fairly new in doing GIS work in R, but I thought this would be a nice situation to get my feet wet. Here is the situation: I need to create multiple plots with the same background, the same ...
1
vote
0answers
821 views

Trying to Create a Global Choropleth Population Density Map then add Biodiversity Level

I am trying, quite unsuccessfully, to create a global choropleth population density map for a specific 120 countries, using ggplot2. Once I have created this choropleth map, I want to add number of ...
2
votes
1answer
456 views

Convert all rasters in a rasterstack to polygons

I need to convert all rasters in a RasterStack to polygons and give the polygons names according to its respective raster. library(raster) ## r is a single raster rpolygon <- rasterToPolygons(r, ...
4
votes
2answers
891 views

Overlaying a polyshape to faceted maps in R with ggplot?

I have managed to create a faceted map from my data following the approach proposed here http://spatial.ly/2013/12/introduction-spatial-data-ggplot2/ with the following code: ggplot(data = plot.data,...
0
votes
1answer
2k views

How to make customized radar chart in R? [closed]

I am a beginner in R language and trying to make this picture. I tried radar. I tried using radarchart (radarchart(data)) but I do not know how to modify the picture. Here is my data: A B ...
2
votes
2answers
364 views

Same colour palettes for two different maps in ggplot2

I am constructing two ion concentration maps in the UK using ggplot2. The dataset used for mapping are lzn.kriged1 and lzn.kriged2 which basically has the same structure: > str(lzn.kriged1) Formal ...
2
votes
0answers
143 views

Plotting gam spatial estimates over map?

I have imported Italy map with the following code: library(ggplot2) library(mgcv) library(ggmap) Country <- "Italy" Get_Map_Country <- get_map( location = Country , zoom = 6 ,...
15
votes
4answers
33k views

Converting osm file to shapefile (or data frame) in R

I was looking for a road shapefile for Australia today. I ended up going to Geofabrik. Open Street Map has data in .osm format. But they do not have one in .shp for Australia. If possible, I want to ...
2
votes
1answer
3k views

Map with ggplot2 and bubbles

I've tried to plot a map of magnitude earthquakes in Colombia with ggplot. After many efforts, I got it. But, I need to focus in specially area where the data of magnitudes is (4, 4.1, 4.2, 4.3, 4.4, ...
3
votes
1answer
582 views

Tearing of polygons using ggmap and readOGR

I'm trying to incorporate a shapefile of US states with ggmap and keep getting "tearing" of my polygons. I tried changing group=id to group=group which helped, but didn't seem to resolve the boundary....
1
vote
1answer
275 views

Tearing of SpatialLinesDataFrame and problem with gClip function

I am trying to use ggmap with geom_map and geom_path commands to add a SpatialPolygonsDataFrame of African countries and a SpatialLinesDataFrame over a raster. When I use the defined function gClip() ...
0
votes
2answers
347 views

ggplot2 adding extra polygons

So, I'm working with a dataset of polygons generated at different levels of sensitivity to error from a citizen science project. I have been trying to visualize how my sensitivity threshold changes ...
1
vote
1answer
533 views

symbols for different polygon layers in ggplot2

I'm trying to plot the boundary of different spatialPolygonsDataFrames in ggplot2 or in rasterVis gplot(), but I just can't find the way, they tend to overwrite the previous one; this is something ...
4
votes
1answer
789 views

ggplot2 fills holes in polygons

I have a shapefile composed of polygons (sample here), many of which have holes in them. I cleaned the polygon layer in GRASS. After cleaning, QGIS's 'Check Geometry Validity' tool returned no errors. ...
3
votes
0answers
36 views

smearing in Linux, but not in Windows

I must have a Linux library out of wack since the following image has "smears" on the colors. Is there a better term? On my Windows 7 RStudio it works fine. this image is from a Ubuntu 16.04 LTS ...
3
votes
1answer
834 views

Ggplot2 map with colored background and coord_map()

I'm trying to plot some cities stored in my rda file naobrazokSR.rda on a map from GADM while having a background of the map in color #2C3E4F. Without using the coord_map() this works as intended but ...
3
votes
1answer
10k views

Why is my stacked area graph in ggplot2 returned as stacked lines? [closed]

I'm having a bit of a problem creating my stacked area chart in ggplot2 in R, for some reason it is returning as a stacked line; e.g. data: library(ggplot2) Sector <- rep(c("S01","S02","S03","...
3
votes
1answer
197 views

fit two sf polygons seamlessly

Copied from my SO question The problem Suppose we have two shapefiles that should border seamlessly. Only, they don't. Is there a way to force them to stick to one another without gaps? The ...
6
votes
1answer
4k views

Anyway to remove points outlying shape in ggplot2?

I am to map a plot of an area and then plot points over it (given by Easting and Northing). However, I found out that there are certain mistakes in the data entered for Easting and Northing resulting ...
1
vote
1answer
925 views

Plotting square grids on a map and extracting each grid information using R [closed]

I have a data set which looks like this LATITUDE LONGITUDE VALUES 28.26734 76.82973 -56.7879 28.26644 76.82972 -58.22462 28.26508 76.82969 -58.4211 28.26778 76.83076 -55.75333 28.26733 76.83075 -...
1
vote
1answer
2k views

Can't plot polygons with R: Invalid number of points in LinearRing found 3 - must be 0 or >= 4?

I want to plot a map of my region, with colour filled polygons using R. I have downloaded municipal (lines) and province (polygons) boundaries. I've used SAGA to merge municipal and province shapes to ...
1
vote
1answer
2k views

Color region polygons according to cluster label?

I want to present data on a map of our country. I have used R for showing the clusters on a country! Here the steps I took: setwd('D:/r/cluster2') channel <- odbcConnectExcel('cluster.xls') data &...
0
votes
2answers
1k views

raster::plot() plotting raster too small- is there an alternative on ggplot?

I am trying to plot this raster on R. The object is quite big, but when plotting it using the raster::plot() function, I obtain a very tiny image, as attached. The code I use to produce it is the ...
6
votes
0answers
2k views

How to prevent cross-world lines in ggplot world map?

I'm having issues displaying 'great circles' paths and polygons in ggmap, an extension of ggplot2. Please enter the following code to replicate my issues: https://gist.github.com/Robinlovelace/...
0
votes
2answers
2k views

Filled Polygons using ggplot in R not working

The following code works well for drawing polygons SP <- SpatialPolygons(spd) centroids <- coordinates(SP) x <- centroids[,1] y <- centroids[,2] SP1 <- SpatialPolygonsDataFrame(SP, ...
1
vote
2answers
590 views

Unable to Export Kriging Prediction Map

I have performed Kriging using the autoKrige function, that is part of the automap package in R. I obtained this as my output I have realized that maybe the reason why I can not export the ...
0
votes
1answer
915 views

Problems in producing animation GIF files in R

I am trying to produce a GIF file for my maps in R using gganimate but errors show up. devtools::install_github("dgrtwo/gganimate") library(ggplot2) data(sp6, package = 'aqp') p <- ggplot(sp6, ...
6
votes
1answer
3k views

How to create a crisp topographical/terrain map with ggplot2?

I am trying to produce a high quality vector based map (in greyshades) in order to report locations. I tried this by getting maps from GADM and SRTM to make a raster as a base for plotting in ...
1
vote
2answers
1k views

Is there a county-level maps dataset that includes independent cities in virginia?

The following code shows the dataset I am working with: library(maps) CountyMapData <- map_data("county") head(CountyMapData) long lat group order region subregion 1 -86.50517 32....