[R-sig-Geo] Contour plot

sownal chand @own@|ch@nd|m@ @end|ng |rom gm@||@com
Tue Apr 5 10:10:00 CEST 2022


Hello sir/madam,

I have been writing codes using R and was trying to overlay contour lines
on the map using the data set provided in the attachment. The code which I
am working on is attached below. The problem is the overlay of the contours
is not showing in the final map. If someone can assist in correcting the
codes would be really appreciated .

 # Packages
#if (!require("rspatial")) remotes::install_github('rspatial/rspatial')
library(rspatial)
library(sp)
library(rgdal)
library(rgoes)
library(raster)
library(ggplot2)

# Fiji geo data
# download
#Draft map of Fiji
world <- rnaturalearth::ne_countries(scale = "Large", returnclass = "sf")

# map of Fiji Islands
Fiji <- ggplot(data=world) +
  geom_sf() +
  coord_sf(
    crs = 3832, # https://epsg.io/3832
    xlim = c(2984265.06, 3539584.72), # limits are taken from projected
bounds
    ylim = c(-2224162.41, -1811688.88)  # of EPSG:3832
  )+ theme_bw()

#Plot map of Fiji
Fiji

#read csv data from excel file for contoure analysis
data.Fdf <- read.csv("C://Users/Sownal/Documents/data.csv")
View(data.Fdf)
class(data.Fdf)

#remove NA values in the spatial Data Frame
data.dfclean <- na.omit(data.Fdf)
data.dfclean

data.dfclean$long <- as.numeric(data$Longitude)
data.dfclean$lat <- as.numeric(data$Latitude)

# convert data to spatial data fame for spatial analysis and raster analysis
data.FSP <- SpatialPointsDataFrame(data= data.dfclean, coords =
data.dfclean$lat, data.dfclean$long)
data.FSP
#select one years data and overlay contours on the Map of Fiji

Fiji <- ggplot(data=world) +
  geom_sf() +
  coord_sf(
    crs = 3832, # https://epsg.io/3832
    xlim = c(2984265.06, 3539584.72), # limits are taken from projected
bounds
    ylim = c(-2224162.41, -1811688.88)  # of EPSG:3832
  )+ theme_bw() + filled.contour(data.dfclean$Year)


# plot the map of Fiji with the contours lines
Fiji

******************************************************************************************************

Thanking you in advance
sownalc

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20220405/31904f5b/attachment.html>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: DataR.csv
Type: text/csv
Size: 628 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20220405/31904f5b/attachment.csv>


More information about the R-sig-Geo mailing list