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
1answer
387 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 ...
2
votes
1answer
2k views

Plotting polygon on Google map?

I have a dataset with points in NYC. I extract the bounding box (max and min lat/lon) and plot it on a map. It works for the basemap stamen watercolor, but not for google's. Why? Here is the code 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, ...
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 ...
2
votes
0answers
38 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. ...
2
votes
0answers
135 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 ,...
2
votes
0answers
305 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(...
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
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
502 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 ...
1
vote
2answers
574 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 ...
1
vote
1answer
589 views

Remove points outside a map with ggplot2

My dataset consist in a converted raster dataframe, with for each point a long/lat, a categorical value and a numerical value are associated with. It can be downloaded here. The code hereafter ...
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 ...
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", ...
1
vote
1answer
815 views

How to spatially smooth data on a map?

I've been struggling a lot lately to produce a map in R with the ggplot2 package. So far this is the map I managed to achieve (where each little plygon stands for a city) : The data used for this ...
1
vote
1answer
345 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 ...
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 ...
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....
1
vote
1answer
1k 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
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
vote
1answer
403 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
59 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 ...
1
vote
1answer
101 views

How do I manage to get my swedish letters

I am trying to do the map in ´ggplot2´ in ´R´. I use this function from rgdal package: mapa <- readOGR(dsn=path.expand("C:/~/SWE_adm_shp"),layer="SWE_adm2") than I do: fortify(mapa) ggplot(mapa,...
1
vote
1answer
871 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 ...
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() ...
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 ...
1
vote
0answers
23 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 <-...
1
vote
0answers
105 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
128 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") ...
1
vote
2answers
892 views

How to correctly plot SpatialPolygonDataFrames in ggplot and substract them in R

I have a landuse shapefile (contains data and script) that plots differently in Base and ggplot, the reason for which remains a myster after countless hours of playing with it. I read in both ...
1
vote
0answers
48 views

How to group different values of a variable so that they plot with same shape?

I have a table with two columns of number X and Y, and one column of strings called crystals. crystals A A B C B D B C Using ggplot2, how can I make a scatter plot of X versus Y with two ...
1
vote
1answer
902 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
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 ...
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
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() ...
1
vote
0answers
801 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 ...
0
votes
2answers
976 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 ...
0
votes
1answer
984 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 ...
0
votes
2answers
333 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 ...
0
votes
1answer
2k views

simple plotting of (latitude, longitude) points on a global map

I have a dataframe like the following: country <- c('US', 'CA','TW') city <- c('Atlanta','Halifax','Taipei') lat <- c(33.8004, 44.6500, 25.0392 ) lon <- c( -84.3865,-63.6000,121.5250 ) ...
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 ...
0
votes
1answer
90 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 ...
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 ...
0
votes
1answer
908 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, ...
0
votes
1answer
622 views

Save a rasterPCA plot as a raster file in R [closed]

Looking to the tutorial in http://bleutner.github.io/RStoolbox/rstbx-docu/rasterPCA.html, in which they show how to do a Principal Component Analysis on raster data, I was wandering whether is it ...
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, ...
0
votes
1answer
415 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 ...
0
votes
1answer
764 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 : ...
0
votes
0answers
23 views

Scale the distance between ticks on x-axis in gglot r [closed]

I have a graph like this. I am interested in the minor change between the range (-3.5, 0.5), however, the occupied only a small portion of the x-axis, so that it's hard to interpret. I tried to use ...
0
votes
0answers
18 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 ...