Example 3 using rgdal (Reading and Plotting Spatial Data)
R
# Load the rgdal package library (rgdal) # Read a shapefile containing polygon data world <- readOGR (dsn = system.file ( "vectors" , package = "rgdal" ), layer = "world" ) # Plot the spatial data plot (world, col = "lightblue" , main = "World Map" ) |
Output:
In this example, we use the rgdal package to read a shapefile containing polygon data representing countries of the world. We use the readOGR() function to read the shapefile, and then we use the plot() function to visualize the spatial data. We specify the col argument to set the fill color for the polygons and add a title to the plot.
Geospatial Data Analysis with R
Geospatial data analysis involves working with data that has a geographic or spatial component. It allows us to analyze and visualize data in the context of its location on the Earth’s surface. R Programming Language is a popular open-source programming language, that offers a wide range of packages and tools for geospatial data analysis.
Contact Us