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
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
0answers
177 views

ggmap with Gauss Krueger coordinates

I am using R for doing a map of groundwater levels which means I have some measurements at some coordinates in the Gauss-Krueger system and I interpolated between these measurements. I want to plot ...
3
votes
1answer
2k views

R/ggplot2 adding an additional line/polygon to a choropleth map

I have a choropleth map that represents the number of states being affected by a storm event. This is shown in the image below. I want to lay a transparent line or polygon over these states to ...
4
votes
1answer
784 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
1answer
83 views

Chaotic geo image in R

I am working with qmap (R package ggmap) and when I enter the following code: qmap("Rotterdam", maptype = "terrain", zoom = 13) + geom_polygon(aes(x = long, y = lat, group = group, fill = ...
1
vote
0answers
247 views

Sub setting shapefile to plot a region and addressing mismatch in ggplot & data

I am plotting India's district map with data (cases). First I read data for each district and district shapefile. Later I merge the two on district. Using fortify data I get ggplot. I get a beautiful ...
1
vote
1answer
875 views

rgdal / ggmap : rotate map data and clip map

I'm trying to plot a map of Toronto with ward boundaries and geocoded data on events over years. But the layout is such that I end up with mostly wasted space in the map. To increase resolution for ...
3
votes
1answer
2k views

Retain “region” elements for when using fortify() on a SpatialLinesDataFrame

I'm layering multiple plots using ggplot2 to create a map of Alaska that combines school location and the major road network. I've learned that despite being labeled "major roads" there is wide ...
6
votes
2answers
967 views

Plot tilted map in R

I would like to plot a tilted map, similar to the image below. I would prefer to do this using ggplot2 but I'm glad if there is a solution using base R. Any ideas on how to do this? Here is a dataset ...
4
votes
2answers
868 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,...
1
vote
2answers
2k views

Remove lines from inside a polygon (shapefile) in r

I have this code which prints the Galápagos Islands. But inside the islands, there are lines that I want to get rid off. How is this possible in R? library(rgdal) library(ggplot2) URL <- "https:/...
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() ...
3
votes
1answer
573 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....
7
votes
1answer
9k views

How to create a continuous scale with distinct/custom color and value breaks with ggplot2 map

As stated in the title, I'm trying to create a continuous scale with distinct color and value breaks within the ggplot2 package in R. I'm using some dummy code to illustrate my problem: library(...
1
vote
1answer
5k views

Error when trying to plot legend for geom_point with ggplot2

Here's some mock code to go along with my problem: #read in libraries library(ggmap) library(sp) library(raster) library(ggplot2) #read in country shapefile, project, fortify for mapping with ...
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, ...
2
votes
1answer
842 views

Trouble adding proportional circles on top of symbolized polygon in ggplot2 map

Data: Zipped ea.ml1 shapefile can be found here, and the country outline can be downloaded here at the GADM site. I've been using the Ethiopia ESRI shapefile. Branch locations are here. Per the ...
6
votes
1answer
11k views

How to create custom discrete color scheme for polygon attributes in ggplot2?

Back again with more questions. :) Data: Zipped ea.ml1 shapefile can be found here, and the country outline can be downloaded here at the GADM site. I've been using the Ethiopia ESRI shapefile. As ...
1
vote
1answer
347 views

Error in converting SpatialPolygonsDataFrame to Data Frame, R Script in QGIS

I am trying to convert a SpatialPolygonsDataFrame layer to a DataFrame to create plots using ggplot2 in an R Script within QGIS. I've used spatial join to append averages of BioClim mean temperature ...
5
votes
1answer
455 views

Use “facet_wrap” in ggplot2 with QGIS?

I'm using QGIS 2.6.1 and R version 3.2.2. I'm struggling to get the syntax on a R Script for creating plots via QGIS processing to work. My understanding is that R syntax in QGIS Processing is ...
9
votes
1answer
4k views

R fortify causing polygons to tear

I'm am having some trouble plotting my spatial data using ggplot2. The map looks fine when plotted using spplot, so I'm assuming that the tearing occurs at the fortify stage. The code is as follows: ...
2
votes
0answers
307 views

About shp for ggmap in the R

I am a new in R and GIS, so I kindly ask you on advice. I had a shp which I want to plot on google map. The shpfile is here: http://www.filedropper.com/exercisestanddata First I do this: ogrInfo(...
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","...
1
vote
1answer
200 views

How can i plot this piece of code with ggplot2? [closed]

I have these vectors of the lakes in New Guinea and the coastline and i want to plot it using ggplot2 exactly as it follows but with a more cool appearance. co<-coastline.shp nglakes<-lakes....
1
vote
1answer
322 views

Phantom artifacts after converting to Robinson projection

I'm using ggplot to create a map using the Robinson projection. Ultimately, I'll be plotting individual countries, but I need to provide continent boundaries as a background layer (since some ...
6
votes
1answer
3k views

ggmap: clip a map

I'm using ggmap to grab Washington DC and I have a shapefile that I downloaded from here: library(ggplot2) library(ggmap) library(maptools) dc = get_map(location = 'DC', zoom = 12) nhbds = ...
12
votes
2answers
2k views

Point overplotting on maps in R (e.g. with ggplot2) - how to push points to the side, mark original positions, combine close-by points …?

I've got a database containing languages, their longitudes and latitudes and a feature value (either category 1, category 2 or both - in the plot these are marked red, blue and green respectively). ...
0
votes
1answer
416 views

TopologyException error during fortify SpatialPolygonsDataFrame

I tried to reproduce a recent question on spatial data visualization using ggplot2 and received the following error message during fortify(world, region = "ISO3"): Error: TopologyException: Input ...
6
votes
1answer
1k views

Plotting data without geographical coordinates besides the main map in ggplot2

I am trying to plot some data as a bubble chart on the world map using ggplot2 package in R. I am able to proceed as follows. # Load necessay packages library(ggplot2) library(rworldmap) library(...
0
votes
1answer
986 views

ggplot2 plots polygons with wrong topologies

I'm trying to plot polygons in R using ggplot2. In GRASS, QGIS and normal R the map renders fine, but ggplot2 seems to have some kind of topological difficultes I can't explain. With normal R it looks ...
5
votes
1answer
2k views

Geographic Heatmaps with Concentric Circles by Distance?

I'm looking to generate a geographic heatmap (using 'ggmap') that overlays some dimension (to start, housing prices) over the lat/lon near a city center. Then I want to create circles of equi-distant ...
5
votes
1answer
601 views

Plotting islands in ggplot2

I'm trying to plot bodies of water on my map and struggling with islands in ggplot2. I understand the right/left-hand rule for exterior/interior rings but there is still a problem going from island to ...
0
votes
1answer
765 views

R using fortify to project shapefile on google map gives wrong results

I have a shapefile that looks like this > str(FieldsMap) Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots ..@ data :'data.frame': 3 obs. of 2 variables: .. ..$ id : ...
1
vote
0answers
88 views

How to solve coordinate differences between packages

I have two maps generated by two different methods. The first, I used maps package and the function map() and symbols(). On the other hand, I used the ggmap package with the ggmap() and geom_point() ...
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/...
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....
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 ...
4
votes
1answer
469 views

Projection mismatch when plotting precipitation with ggplot

I'm trying to plot accumulated precipitation in Brazil for a given period, see code below: Load packages library(raincpc) library(SDMTools) library(raster) library(ggplot2) library(rgdal) library(...
0
votes
1answer
615 views

ggmap fortify start and end jumble

I have a census tiger line file for counties available from the Census website. I am trying to display this file on a ggmap, but fortify seems to jumble the regions. I can't find anyone else who has ...
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 &...
1
vote
0answers
802 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 ...
10
votes
2answers
1k views

Help choosing most suitable bivariate choropleth mapping coloring scheme

I am trying to overlay a nominal variable (2 categories - rainfed vs irrigated) in a choropleth map over a numeric variable. In order to highlight the difference in pattern among the two categories, ...
4
votes
2answers
1k views

How can I create a choropleth from the 2010 census ZCTA shapefile using R and ggplot2?

I have created state and county choropleths in R using ggplot2. The method I have used for this came from Winston Chang's "R Graphics Cookbook". For those choropleths the map was already represented ...
2
votes
1answer
178 views

Shapefile for linked micromap is not working

I am trying to replicate the example provided in the micromap R package of a linked map with the poverty rate for the 50 US states. I am trying to achieve the same results with a Shapefile from ...
3
votes
1answer
689 views

plotting a SpatialPolygons object using lines() without lines connecting separate polygons

This is almost an extension of a question asked on stackoverflow (https://stackoverflow.com/questions/12196440/extract-feature-coordinates-from-spatialpolygons-and-other-sp-classes), so I'll use the ...
3
votes
2answers
1k views

How to use ggplot with Processing in QGIS 2.0?

I'm trying to use R scripts within QGIS thanks to Processing. There are some example scripts available and I achieved to plots different columns of the attribute table (with the plot built-in package)....
2
votes
2answers
765 views

Plotting a certain range in azimuthal projection using ggplot2

I would like to limit a map to a particular range of values (i.e. northern hemisphere) under an azimuthal or orthographic projection in ggplot2. When I set ylim, I receive an error message that ...
1
vote
1answer
1k 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 ...
4
votes
0answers
1k views

Fortifying re-projected shapefile for ggplot2 in R

I have a shapefile of US county boundaries which I got from the NHGIS. I can load the file using the rgdal package and see information about it: library(rgdal) shp_1860 <- readOGR("shp", "...
6
votes
1answer
3k views

Loading a png image as a map with ggplot2/ggmap

I am trying to find a workaround for ggmap's missing support of world maps (i.e. you can't create any maps that show latitudes > 80°, due to idiosyncrasies in the mapproj package). To a limited extend ...