Skip to content

readOGR not reading in prj file?

7 messages · Vinh Nguyen, Denis mutiibwa

#
Hi,

I'm currently using rgdal v 1.1-1 on R 3.2.2.  It appears my
projection file is not being read in by readOGR:
OGR data source with driver: ESRI Shapefile
Source: "FloodShapes", layer: "2013Spring_Flood_Drawn"
with 8 features
It has 2 fields
[1] NA

I have to manually pass in the CRS:
OGR data source with driver: ESRI Shapefile
Source: "FloodShapes", layer: "2013Spring_Flood_Drawn"
with 8 features
It has 2 fields
[1] "+init=EPSG:3857 +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0
+lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"

Any thoughts on why readOGR doesn't automatically read in the prj
file?  Here's the content of the prj file:
PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]

Thanks so much for your help.

-- Vinh
#
Hi Vinh,proj4string function is giving you NA because "shapebase" shapefile doesn't have an auxiliary file "shapebase.prj"?Denis Mutiibwa,
On Wednesday, April 6, 2016 10:46 AM, Vinh Nguyen <vinhdizzo at gmail.com> wrote:
>Hi,
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
#
On Wed, Apr 6, 2016 at 8:24 AM, Denis mutiibwa <mutiibwa2000 at yahoo.com> wrote:
Thanks for your response Denis.  The following files are all in the directory:
2014Spring_Flood_Drawn.cpg  2014Spring_Flood_Drawn.sbx
2014Spring_Flood_Drawn.dbf  2014Spring_Flood_Drawn.shp
2014Spring_Flood_Drawn.prj  2014Spring_Flood_Drawn.shp.xml
2014Spring_Flood_Drawn.sbn  2014Spring_Flood_Drawn.shx

So, the prj file is there...or am I misunderstanding?  Thanks.

-- Vinh
#
Where is "shapebase" coming from?If those are the files in the directory, your scripts should as below:dir.path <- directory pathdFloodRisk <- readOGR(dir.path, "2014Spring_Flood_Drawn")proj4string(dFloodRisk)?
Denis Mutiibwa
On Wednesday, April 6, 2016 11:32 AM, Vinh Nguyen <vinhdizzo at gmail.com> wrote:

        
On Wed, Apr 6, 2016 at 8:24 AM, Denis mutiibwa <mutiibwa2000 at yahoo.com> wrote:

  
  
#
On Wed, Apr 6, 2016 at 8:41 AM, Denis mutiibwa <mutiibwa2000 at yahoo.com> wrote:
I'm reading the files in exactly as you are suggesting (floodshapedir
and shapebase are variables) as seen in the output below:
OGR data source with driver: ESRI Shapefile
Source: "FloodShapes", layer: "2013Spring_Flood_Drawn"

Just not sure why the prj file is not being read in.  Thanks.

-- Vinh
#
readOGR(dir.path, "argv2")
it seems "argv2" has to be the shapefile name not a variable name ??Denis Mutiibwa
On Wednesday, April 6, 2016 11:54 AM, Vinh Nguyen <vinhdizzo at gmail.com> wrote:

        
On Wed, Apr 6, 2016 at 8:41 AM, Denis mutiibwa <mutiibwa2000 at yahoo.com> wrote:

  
  
#
On Wed, Apr 6, 2016 at 8:58 AM, Denis mutiibwa <mutiibwa2000 at yahoo.com> wrote:
My 'floodshapedir' and 'shapebase' are both variables with path stored
in.  Here's the function call with the strings explicitly passed.  I
don't think it's an issue with these paths.
OGR data source with driver: ESRI Shapefile
Source: "FloodShapes", layer: "2013Spring_Flood_Drawn"
with 8 features
It has 2 fields
[1] NA

-- Vinh