Example 1: Importing and Plotting Spatial Data (Vector)

R




# Load the sf package
library(sf)
 
# Read a shapefile containing polygon data
world <- st_read(system.file("shape/nc.shp", package="sf"))
 
# Plot the spatial data
plot(world)


Output:

Introduction to Geospatial Data Analysis with R

we load the sf package and read a shapefile containing polygon data representing North Carolina counties. We then plot the spatial data using the plot() function.

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.

Similar Reads

fundamental concepts of Geospatial data

1. Spatial Data Types...

Example 1: Importing and Plotting Spatial Data (Vector)

R # Load the sf package library(sf)   # Read a shapefile containing polygon data world <- st_read(system.file("shape/nc.shp", package="sf"))   # Plot the spatial data plot(world)...

Example 2: Raster Data Analysis

...

Example 3 using rgdal (Reading and Plotting Spatial Data)

R # Load required packages library(raster)   # Read a raster dataset (elevation data) elevation <- raster(system.file("external/test.grd", package="raster"))   # Compute statistics on the elevation data elev_summary <- summary(elevation)   # Display the summary statistics print(elev_summary)...

Example 4 using sp (Spatial Data Manipulation and Visualization)

...

Contact Us