TransWikia.com

How to plot shapefile in R

Geographic Information Systems Asked by fionant97 on September 29, 2020

I am trying to plot a shapefile on top of a raster using the command readOGR. My current code is:

    CEZ <- readOGR(".", "Shapefile/CEZ1")

This is followed by the error code

Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, :
Cannot open data source

I am unsure what this code means – Is it a problem with the shapefile, the command or the way I have structured the path?

One Answer

The raster package has a handy wrapper function for reading shapefiles. You should be able to do:

library(raster)
CEZ <- shapefile("./Shapefile/CEZ1.shp")

if that's where your shapefile really is. You might get a better error message.

Answered by Spacedman on September 29, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP