[R-sig-Geo] Mapping Pacific centered map for Spatial analysis

sownal chand @own@|ch@nd|m@ @end|ng |rom gm@||@com
Sun Mar 13 17:39:30 CET 2022


Hi Micha

Firstly thank you very very much. I have been trying to do this for quite
some time.

I will follow your codes and if I have any questions will let you know.

For the times series analysis for temperature, I am still thinking for the
best solutions to go about doing it.

If you have a better technique do let me know so that I can be as
accurate as possible.

Requesting if you can show some light in time series data analysis would
really help.

Yours sincerely
Sownal



On Mon, Mar 14, 2022, 03:38 Micha Silver <tsvibar using gmail.com> wrote:

> Hi:
>
>
> I've prepared an alternative to your code, with some ideas that might
> help. Following Roger's comment, I transformed the spatial layers to
> EPSG:3460. The code is attached.
>
>
> I also have a few comments. Inline, below:
>
>
> On 13/03/2022 11:26, sownal chand wrote:
> > Hello Micha,
> >
> > Thank you for your prompt response. I am attaching my codes and sample
> > data for your reference.
> > As I mentioned earlier, I am trying to interpolate climate data using
> > IDW and visualize the Climate change that is happening in My country
> > from the past 55years till date (2021).
> > Moving forward, I am new to spatial interpolation using R and would
> > like to write codes in R so that it is easy to notice the changes in
> > the average temperature, Max, Min temperature, rainfall and
> > other climate variables.
> >
>
> First, you're using some older packages (rgdal and rgeos). Today it
> makes sense to switch to the newer sf without those dependencies.
>
>
> >
> > # import libraries
> > library(raster)
> > library(ggmap)
> > library(RgoogleMaps)
> > library(rgdal)
> > library(ggplot2)
> > library(rnaturalearth)
> > library(dplyr)
> > library(tidyr)
> > library(gstat)
> > library(rgeos)
> > library(scales)
> > options(stringsAsFactors = FALSE)
> >
> > # Fiji geo data & study Area
> > # download
> > #Draft map of Fiji
> > Fiji_studyarea <- readOGR("../input/fijishp/FJI_adm2.shp")
> > extent(Fiji_studyarea)
> >
> > # import climate data - netcdf format
> > Temp <- read.csv("../input/TempData/53YearsTemper.csv")
> > Temp
> > str(Temp)
> >
>
> This data file is in "wide" format. In the example I show how to make it
> "tidy" for further plotting and analysis.
>
>
> > # check out our one years data
> > Temp$Year.3
> >
> > # remove NA values
> > Temp <- Temp %>%
> >   drop_na()
> > Temp
> >
> > # create spatial points object
> > Temp_sp <- Temp
> > class(Temp_sp)
> >
> > # convert the data into spatial coordinates
> > coordinates(Temp_sp) <- ~long + lat
> > class(Temp_sp)
> >
> > # view spatial points
> > plot(Temp_sp$Year,
> >      main = "Average Temperature for year 1965")
> >
>
> Next, you have data from only a few, widely spaced stations, and IDW
> might not be the best interpolation method. But that's for you to decide.
>
>
>
> > ##### IDW interpolation ##### From here the code gives errors as the
> > interpolation area is very small.
> > # establish an extent within which you want to interpolate
> > x_range <- as.numeric(c(290.00, 360.00))  # min/max longitude of the
> > interpolation area
> > y_range <- as.numeric(c(-23.00, -17.00))  # min/max latitude of the
> > interpolation area
> >
>
> With gstat you can now use a stars object as target grid. See my example.
>
>
> > # create an empty grid of values ranging from the xmin-xmax, ymin-ymax
> > grd <- expand.grid(x = seq(from = x_range[1],
> >                    to = x_range[2],
> >                    by = 0.1),
> >                    y = seq(from = y_range[1], to = y_range[2],
> >                        by = 0.1))  # expand points to grid
> > class(grd)
> >
> > # crs = 3832, # https://epsg.io/3832 Pacific centered CRS
> >
> > # interpolate the data
> > idwTemp_pow1 <- idw(formula = Temp$Year ~ 1,
> >            locations = Temp_sp,
> >            newdata = grd,
> >            idp = 1)
> >
> > # plot the data
> > plot(idw_pow1,
> >      col = terrain.colors(55))
> >
> >
> > Please can you assist in correcting these errors. and the shapefile
> > does not show on the map. OR you can give a better option of codes to
> > follow doing this.
> >
> > Really appreciate your assistance and thanking you in advance
> >
> >
>
> Final comment. You mentioned a time series analysis to follow climate
> change. You'll have to decide how you want to go about this. Are you
> going to prepare interpolations for each year, then do a pixel by pixel
> change detection? In my example I show a simple time series plot of
> temperature data, by station.
>
>
> HTH
>
> Regards, Micha
>
>
> >
> >
> >
> >
> > On Sun, 13 Mar 2022 at 20:45, Micha Silver <tsvibar using gmail.com> wrote:
> >
> >
> >     On 13/03/2022 01:41, sownal chand wrote:
> >     > Hello Sir/Madam,
> >     >
> >     > I am Sownal Chand, from Fiji Islands and am currently working on
> >     a project
> >     > which involves spatial analysis of climate data (Temperature,
> >     rainfall,
> >     > etc). I have been able to write codes in R for Point
> >     interpolations of
> >     > these parameters but I require some assistance in mapping these
> >     raster
> >     > files on the southwest pacific maps. For example, a map of Fiji
> >     Islands  (
> >     > https://www.pinterest.com/pin/740982944911004875 ) and I am
> >     facing some
> >     > difficulties in making these plots.
> >     >
> >     > I hope that some expert would be willing to help me with this
> >     and the map's
> >     > CRS setting is a bit confusing and I am a beginner in this area
> >     ( i. e,
> >     > spatial analysis using R). I have been looking at tutorials and
> >     codes to
> >
> >
> >     There are tons of online resources. You could, for example, refer to:
> >
> >     https://geocompr.robinlovelace.net/
> >
> >
> >     > crop country boundaries and shapefiles and still found lots of
> >     errors in my
> >     > codes.
> >
> >
> >     You have raised a few different questions. Would you mind to post
> >     what
> >     you have done so far, and point out the errors and difficulties?
> >
> >
> >     > Hoping to find solutions to my problems and learn from this.
> >     >
> >     > yours sincerely
> >     > sownalc
> >     > Contact: sownalchand using gmail.com
> >     > PH +679 2960779
> >     >
> >     >       [[alternative HTML version deleted]]
> >     >
> >     > _______________________________________________
> >     > R-sig-Geo mailing list
> >     > R-sig-Geo using r-project.org
> >     > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
> >     --
> >     Micha Silver
> >     Ben Gurion Univ.
> >     Sde Boker, Remote Sensing Lab
> >     cell: +972-523-665918
> >
> --
> Micha Silver
> Ben Gurion Univ.
> Sde Boker, Remote Sensing Lab
> cell: +972-523-665918
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list